ZennyKenny commited on
Commit
0bb000c
·
verified ·
1 Parent(s): ac05e10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -9
app.py CHANGED
@@ -2,7 +2,7 @@ import streamlit as st
2
  import requests
3
  from bs4 import BeautifulSoup
4
  import trafilatura
5
- from smolagents import Agent
6
 
7
  # Streamlit UI
8
  def main():
@@ -51,13 +51,22 @@ def find_relevant_article(base_url, question):
51
 
52
  # Step 5: Generate Answer using `smolagents`
53
  def generate_answer(question, context):
54
- agent = Agent("Question-Answering Agent", description="Answers questions based on documentation.")
55
- prompt = f"""
56
- Context: {context}
57
- Question: {question}
58
- Provide a clear and concise answer.
59
- """
60
- return agent.run(prompt)
 
 
 
 
 
 
 
 
 
61
 
62
  if __name__ == "__main__":
63
- main()
 
2
  import requests
3
  from bs4 import BeautifulSoup
4
  import trafilatura
5
+ from smolagents import create_agent
6
 
7
  # Streamlit UI
8
  def main():
 
51
 
52
  # Step 5: Generate Answer using `smolagents`
53
  def generate_answer(question, context):
54
+ """Defines an AI agent to generate answers based on documentation context."""
55
+
56
+ def answer_logic(state):
57
+ """Agent logic to answer based on context."""
58
+ return f"Based on the documentation, here is my answer: {state['context'][:500]}..." # Truncating for brevity
59
+
60
+ # Create the agent
61
+ agent = create_agent(
62
+ name="QA_Agent",
63
+ description="Answers questions based on documentation content.",
64
+ process=answer_logic,
65
+ )
66
+
67
+ # Run the agent
68
+ response = agent({"context": context, "question": question})
69
+ return response
70
 
71
  if __name__ == "__main__":
72
+ main()