You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importosimportinstructorfromdotenvimportdotenv_valuesfrompydanticimportBaseModel, Fieldfromvertexai.generative_modelsimportGenerativeModelconfig=dotenv_values(".env")
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] =config["GOOGLE_APPLICATION_CREDENTIALS"]
client=instructor.from_vertexai(
client=GenerativeModel("gemini-1.5-flash-002"),
mode=instructor.Mode.VERTEXAI_TOOLS,
)
last_line_number=2annotated_content="Line 0: a\nLine 1: b\nLine 2: c"system_prompt=f"""You are an expert web content analyzer. Your task is to analyze the provided webpage text and generate 3 topic headings that cover the full content of the webpage. For each topic heading, you must also provide the starting and ending line numbers of the corresponding section. Each section is the continuation of the previous section.The line numbers must be integers, start from `0`, and end at the last line `{last_line_number}`. There should be no overlap between the line number ranges.""".strip()
classTopicHeading(BaseModel):
reasoning: str=Field(
description="The reasoning process of why the topic heading and line numbers are chosen."
)
heading: str=Field(description="The topic heading for a section of the webpage.")
start_line: int=Field(description="The starting line number of the section.")
end_line: int=Field(description="The ending line number of the section.")
classWebpageTopics(BaseModel):
topics: list[TopicHeading] =Field(
description="A list of topic headings with their corresponding start and end line numbers."
)
resp, completion=client.chat.completions.create_with_completion(
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": annotated_content},
],
response_model=WebpageTopics
)
print(resp)
Expected behavior
system role should be supported like OpenAI
The text was updated successfully, but these errors were encountered:
What Model are you using?
Describe the bug
Not able to use system role
To Reproduce
Expected behavior
system role should be supported like OpenAI
The text was updated successfully, but these errors were encountered: