Omar Solano commited on
Commit
e951b9f
Β·
1 Parent(s): 88c845c

add sources to answer

Browse files
Files changed (2) hide show
  1. scripts/gradio-ui.py +3 -12
  2. scripts/tutor_prompts.py +3 -1
scripts/gradio-ui.py CHANGED
@@ -163,7 +163,7 @@ custom_retriever = CustomRetriever(vector_retriever, document_dict)
163
 
164
 
165
  def format_sources(completion) -> str:
166
- if len(completion.source_nodes) == 0:
167
  return ""
168
 
169
  # Mapping of source system names to user-friendly names
@@ -186,7 +186,7 @@ def format_sources(completion) -> str:
186
  ),
187
  url=src.metadata["url"],
188
  )
189
- for src in completion.source_nodes
190
  ]
191
  )
192
 
@@ -257,19 +257,10 @@ def generate_completion(
257
  retriever=custom_retriever,
258
  metadata=ToolMetadata(
259
  name="AI_information",
260
- description="""Only use this tool if necessary. The 'AI_information' tool is a comprehensive repository for information in artificial intelligence (AI). When utilizing this tool, the input should be the user's question rewritten as a statement. The input can also be adapted to focus on specific aspects or further details of the current topic under discussion. This dynamic input approach allows for a tailored exploration of AI subjects, ensuring that responses are relevant and informative. Employ this tool to fetch nuanced information on topics such as model training, fine-tuning, and LLM augmentation, thereby facilitating a rich, context-aware dialogue. """,
261
  ),
262
  )
263
  ]
264
- # query_engine_tools = [
265
- # QueryEngineTool(
266
- # query_engine=custom_query_engine,
267
- # metadata=ToolMetadata(
268
- # name="AI_information",
269
- # description="""Only use this tool if necessary. The 'AI_information' tool is a comprehensive repository for information in artificial intelligence (AI). When utilizing this tool, the input should be the user's question rewritten as a statement. The input can also be adapted to focus on specific aspects or further details of the current topic under discussion. This dynamic input approach allows for a tailored exploration of AI subjects, ensuring that responses are relevant and informative. Employ this tool to fetch nuanced information on topics such as model training, fine-tuning, and LLM augmentation, thereby facilitating a rich, context-aware dialogue. """,
270
- # ),
271
- # )
272
- # ]
273
 
274
  if model == "gemini-1.5-flash" or model == "gemini-1.5-pro":
275
  # agent = AgentRunner.from_llm(
 
163
 
164
 
165
  def format_sources(completion) -> str:
166
+ if len(completion.sources) == 0:
167
  return ""
168
 
169
  # Mapping of source system names to user-friendly names
 
186
  ),
187
  url=src.metadata["url"],
188
  )
189
+ for src in completion.sources[0].raw_output
190
  ]
191
  )
192
 
 
257
  retriever=custom_retriever,
258
  metadata=ToolMetadata(
259
  name="AI_information",
260
+ description="""Only use this tool if necessary. The 'AI_information' tool is a comprehensive repository for information in artificial intelligence (AI). When using this tool, the input should be the user's question rewritten as a statement. e.g. When the user asks 'How can I fine-tune an LLM?', the input should be 'Fine-tune an Large Language Model (LLM)'. The input can also be adapted to focus on specific aspects or further details of the current topic under discussion. This dynamic input approach allows for a tailored exploration of AI subjects, ensuring that responses are relevant and informative. Employ this tool to fetch nuanced information on topics such as model training, fine-tuning, and LLM augmentation, thereby facilitating a rich, context-aware dialogue. """,
261
  ),
262
  )
263
  ]
 
 
 
 
 
 
 
 
 
264
 
265
  if model == "gemini-1.5-flash" or model == "gemini-1.5-pro":
266
  # agent = AgentRunner.from_llm(
scripts/tutor_prompts.py CHANGED
@@ -86,7 +86,9 @@ system_message_openai_agent = """You are an AI teacher, answering questions from
86
 
87
  Your answers are aimed to teach students, so they should be complete, clear, and easy to understand.
88
 
89
- Utilize the AI_information tool to gather insights pertinent to the field of AI. This function accepts a string (user question rewritten as a statement) and returns informative content regarding the domain of AI.
 
 
90
 
91
  Only some information returned by the tool might be relevant to the question, so ignore the irrelevant part and use the relevant part to answer the question.
92
 
 
86
 
87
  Your answers are aimed to teach students, so they should be complete, clear, and easy to understand.
88
 
89
+ Use the AI_information tool to gather insights pertinent to the field of AI. This function accepts a string (user question rewritten as a statement) and returns informative content regarding the domain of AI.
90
+
91
+ User question: How can I fine-tune an LLM?, input to the AI_information tool: 'Fine-tune an Large Language Model (LLM)'
92
 
93
  Only some information returned by the tool might be relevant to the question, so ignore the irrelevant part and use the relevant part to answer the question.
94