Spaces:
Build error
Build error
| from typing import TypedDict, Annotated, Literal, Union, Any, List, Tuple | |
| """ | |
| Typing: | |
| Union = either type A or type B | |
| Optional = either type A or None | |
| Literal = only specific values (constants), not any value of a type | |
| """ | |
| from pydantic import BaseModel | |
| import os | |
| import re | |
| import random | |
| import requests | |
| import inspect | |
| import subprocess | |
| import gradio as gr | |
| import pandas as pd | |
| # from lmnr import Laminar | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| from together import Together | |
| import base64 | |
| import yt_dlp | |
| import datasets | |
| from datasets import load_dataset | |
| from huggingface_hub import list_models | |
| from langchain.docstore.document import Document | |
| from langchain_community.retrievers import BM25Retriever | |
| from langchain_community.tools import DuckDuckGoSearchRun | |
| from langchain_community.document_loaders import UnstructuredExcelLoader | |
| from langchain_community.tools import WikipediaQueryRun | |
| from langchain_community.utilities import WikipediaAPIWrapper | |
| from langchain.tools import Tool | |
| from langchain_ollama import ChatOllama | |
| from langchain_together import ChatTogether | |
| from langchain_huggingface import HuggingFaceEndpoint,ChatHuggingFace | |
| from langchain_core.messages import AnyMessage, HumanMessage, AIMessage, SystemMessage, ToolMessage | |
| from langgraph.graph import StateGraph, START, END | |
| from langgraph.graph.message import add_messages | |
| from langgraph.prebuilt import tools_condition, ToolNode | |
| from langsmith import traceable | |
| # GLOBALS | |
| HF_TOKEN = os.getenv('HF_TOKEN') | |
| LAMINAR_API_KEY = os.getenv('LAMINAR_API_KEY') | |
| # from the task | |
| DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space" | |
| api_url = DEFAULT_API_URL | |
| questions_url = f"{api_url}/questions" | |
| submit_url = f"{api_url}/submit" | |
| file_url = f"{api_url}/files" | |
| # DEFAULT_SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise.If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.""" | |
| DEFAULT_SYSTEM_PROMPT = """ | |
| You are a general AI assistant. | |
| I will ask you a question. | |
| Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. | |
| YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. | |
| If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. | |
| If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. | |
| If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string. | |
| """ | |
| # Think step by step. On every step use a tool if it is needed. Make multiple tool calls if required. | |
| DEFAULT_SYSTEM_PROMPT = DEFAULT_SYSTEM_PROMPT.replace("\n", "") | |
| # model_name = 'qwen3:8b' | |
| model_name = 'llama3.2:latest' | |