Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,8 @@ from typing import Annotated
|
|
| 3 |
from typing_extensions import TypedDict
|
| 4 |
from langgraph.graph import StateGraph, START, END
|
| 5 |
from langgraph.graph.message import add_messages
|
| 6 |
-
from langchain_anthropic import ChatAnthropic
|
|
|
|
| 7 |
from dotenv import load_dotenv
|
| 8 |
import logging
|
| 9 |
|
|
@@ -12,11 +13,18 @@ logging.basicConfig(level=logging.INFO)
|
|
| 12 |
|
| 13 |
|
| 14 |
load_dotenv()
|
| 15 |
-
ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY")
|
| 16 |
-
|
| 17 |
|
| 18 |
# Initialize Anthropic Chat model
|
| 19 |
-
llm = ChatAnthropic(model="claude-3-5-sonnet-20240620", anthropic_api_key=ANTHROPIC_API_KEY)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# Define the state structure
|
| 22 |
class State(TypedDict):
|
|
|
|
| 3 |
from typing_extensions import TypedDict
|
| 4 |
from langgraph.graph import StateGraph, START, END
|
| 5 |
from langgraph.graph.message import add_messages
|
| 6 |
+
#from langchain_anthropic import ChatAnthropic
|
| 7 |
+
from langchain_huggingface import HuggingFaceEndpoint
|
| 8 |
from dotenv import load_dotenv
|
| 9 |
import logging
|
| 10 |
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
load_dotenv()
|
| 16 |
+
#ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY")
|
| 17 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 18 |
|
| 19 |
# Initialize Anthropic Chat model
|
| 20 |
+
#llm = ChatAnthropic(model="claude-3-5-sonnet-20240620", anthropic_api_key=ANTHROPIC_API_KEY)
|
| 21 |
+
|
| 22 |
+
llm = HuggingFaceEndpoint(
|
| 23 |
+
repo_id="mistralai/Mistral-7B-Instruct-v0.3",
|
| 24 |
+
huggingfacehub_api_token=HF_TOKEN.strip(),
|
| 25 |
+
temperature=0.7,
|
| 26 |
+
max_new_tokens=200
|
| 27 |
+
)
|
| 28 |
|
| 29 |
# Define the state structure
|
| 30 |
class State(TypedDict):
|