import weaveweave.init('intro-example')# highlight-next-linesystem_prompt = weave.StringPrompt("Talk like a pirate. I need to know I'm listening to a pirate.")weave.publish(system_prompt, name="pirate_prompt")from openai import OpenAIclient = OpenAI()response = client.chat.completions.create( model="gpt-4o", messages=[ { "role": "system", # highlight-next-line "content": system_prompt.format() }, { "role": "user", "content": "Explain general relativity in one paragraph." } ],)
import weaveweave.init('intro-example')# highlight-next-lineprompt = weave.MessagesPrompt([ { "role": "system", "content": "You are a stegosaurus, but don't be too obvious about it." }, { "role": "user", "content": "What's good to eat around here?" }])weave.publish(prompt, name="dino_prompt")from openai import OpenAIclient = OpenAI()response = client.chat.completions.create( model="gpt-4o", # highlight-next-line messages=prompt.format(),)
import weaveweave.init('intro-example')# highlight-next-lineprompt = weave.MessagesPrompt([{ "role": "system", "content": "You will be provided with a description of a scene and your task is to provide a single word that best describes an associated emotion."},{ "role": "user", "content": "{scene}"}])weave.publish(prompt, name="emotion_prompt")from openai import OpenAIclient = OpenAI()response = client.chat.completions.create( model="gpt-4o", # highlight-next-line messages=prompt.format(scene="A dog is lying on a dock next to a fisherman."),)
このページは役に立ちましたか?
Assistant
Responses are generated using AI and may contain mistakes.