Created
August 14, 2024 22:05
-
-
Save elijahbenizzy/b72ba6f20305ffe24ef1c3cb9a4a025a to your computer and use it in GitHub Desktop.
choose_mode_instrumented.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@action(reads=["prompt"], writes=["mode"]) | |
def choose_mode(state: State, __tracer) -> Tuple[dict, State]: | |
prompt = ... | |
with __tracer("query_openai") as tracer: | |
result = _get_openai_client().chat.completions.create( | |
model="gpt-4", | |
messages=[ | |
{"role": "system", "content": "You are a helpful assistant"}, | |
{"role": "user", "content": prompt}, | |
], | |
) | |
tracer.log_attributes(prompt=prompt, model="gpt-4", result=json.dumps(result)) | |
... # continue as normal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment