Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,15 +3,28 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 10 |
|
| 11 |
# --- Basic Agent Definition ---
|
| 12 |
-
# ----- THIS IS
|
| 13 |
class BasicAgent:
|
| 14 |
def __init__(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
print("BasicAgent initialized.")
|
| 16 |
def __call__(self, question: str) -> str:
|
| 17 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from typing import TypedDict, Optional, Annotated
|
| 7 |
+
from langchain_core.messages import AnyMessage
|
| 8 |
+
from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class State(TypedDict):
|
| 12 |
+
input_file_path = Optional[str]
|
| 13 |
+
messages = Annotated[list[AnyMessage], add_messages]
|
| 14 |
|
| 15 |
# (Keep Constants as is)
|
| 16 |
# --- Constants ---
|
| 17 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 18 |
|
| 19 |
# --- Basic Agent Definition ---
|
| 20 |
+
# ----- THIS IS WHERE YOU CAN BUILD WHAT YOU WANT ------
|
| 21 |
class BasicAgent:
|
| 22 |
def __init__(self):
|
| 23 |
+
llm = HuggingFaceEndpoint(repo_id="Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 24 |
+
chat = ChatHuggingFace(llm=llm, verbose=True)
|
| 25 |
+
messages = [("system", "You are a helpful translator. Translate the user sentence to French."),
|
| 26 |
+
("human", "I love programming.")
|
| 27 |
+
print(chat.invoke(messages))
|
| 28 |
print("BasicAgent initialized.")
|
| 29 |
def __call__(self, question: str) -> str:
|
| 30 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|