-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtagging_fields_chainfunction
More file actions
35 lines (27 loc) · 913 Bytes
/
Copy pathtagging_fields_chainfunction
File metadata and controls
35 lines (27 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from langchain.chat_models import ChatOpenAI
from langchain.chains import create_tagging_chain, create_tagging_chain_pydantic
from langchain.prompts import ChatPromptTemplate
from enum import Enum
from pydantic import BaseModel, Field
llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo-0613", openai_api_key=openai_api_key)
class DataScienceQuery(BaseModel):
model: str = Field(
...,
description="This is the Model.",
)
field1: str = Field(
...,
description="This is Field1.",
)
field2: str = Field(
...,
description="This is Field2",
)
time: str = Field(
...,
description="This is time period",
)
chain = create_tagging_chain_pydantic(DataScienceQuery, llm)
user_query = "Can you do a time series analysis and help me predict the sales for next 12 months"
result_query = chain.run(user_query)
result_query