AGiorni commited on
Commit
5a7d4ca
·
1 Parent(s): 81917a3

first commit

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. main_agent.py +44 -0
  3. test.ipynb +0 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .env
main_agent.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # imports
2
+ from typing import TypedDict, Annotated
3
+ from langgraph.graph.message import add_messages
4
+ from langchain_core.messages import AnyMessage
5
+ from langchain_openai import AzureChatOpenAI
6
+ from langgraph.graph import START, StateGraph
7
+
8
+ import os
9
+ from dotenv import load_dotenv
10
+
11
+ # load environment variables
12
+ load_dotenv() # take environment variables
13
+
14
+ # define state
15
+ class State(TypedDict):
16
+ messages: Annotated[list[AnyMessage], add_messages]
17
+
18
+ # create llm interface
19
+ llm = AzureChatOpenAI(
20
+ deployment_name = os.environ.get("AZURE_OPENAI_DEPLOYMENT_NAME"),
21
+ openai_api_key = os.environ.get("AZURE_OPENAI_API_KEY"),
22
+ azure_endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT"),
23
+ openai_api_version = os.environ.get("OPENAI_API_VERSION"),
24
+ temperature=0
25
+ )
26
+
27
+ # define nodes
28
+ def assistant(state: State):
29
+ return {
30
+ "messages": [llm.invoke(state["messages"])],
31
+ }
32
+
33
+ # define graph
34
+ builder = StateGraph(State)
35
+
36
+ # add nodes
37
+ builder.add_node("assistant", assistant)
38
+
39
+ # define edges
40
+ builder.add_edge(START, "assistant")
41
+ # No conditional edges in this simple example
42
+
43
+ # compile gtaph
44
+ graph = builder.compile()
test.ipynb ADDED
File without changes