AksharaSachin commited on
Commit
bb2cef3
·
verified ·
1 Parent(s): 309b281

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -18
app.py CHANGED
@@ -3,19 +3,6 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
6
- from langchain_community.chat_models import ChatOllama
7
- from langchain_community.tools import DuckDuckGoSearchRun
8
- from langchain.agents import Tool, AgentExecutor, initialize_agent
9
- from langchain.agents.agent_types import AgentType
10
- from langchain.prompts.chat import SystemMessagePromptTemplate, ChatPromptTemplate, HumanMessagePromptTemplate
11
- from langchain_huggingface import HuggingFaceEndpoint
12
- from huggingface_hub import login
13
- from langchain.llms import HuggingFaceHub
14
- from agent import build_agent
15
- from langchain_core.messages import HumanMessage
16
-
17
-
18
-
19
 
20
  # (Keep Constants as is)
21
  # --- Constants ---
@@ -53,8 +40,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
53
 
54
  # 1. Instantiate Agent ( modify this part to create your agent)
55
  try:
56
- # llm = ChatOllama(model="llama3.1")
57
- agent = build_agent()
58
  except Exception as e:
59
  print(f"Error instantiating agent: {e}")
60
  return f"Error initializing agent: {e}", None
@@ -94,9 +80,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
94
  print(f"Skipping item with missing task_id or question: {item}")
95
  continue
96
  try:
97
- input_state = {"messages": question_text}
98
- answer = agent.invoke(input_state)
99
- submitted_answer = answer['messages'][-1].content
100
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
101
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
102
  except Exception as e:
 
3
  import requests
4
  import inspect
5
  import pandas as pd
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
 
40
 
41
  # 1. Instantiate Agent ( modify this part to create your agent)
42
  try:
43
+ agent = BasicAgent()
 
44
  except Exception as e:
45
  print(f"Error instantiating agent: {e}")
46
  return f"Error initializing agent: {e}", None
 
80
  print(f"Skipping item with missing task_id or question: {item}")
81
  continue
82
  try:
83
+ submitted_answer = agent(question_text)
 
 
84
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
85
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
86
  except Exception as e: