mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-04-02 08:58:11 +02:00
update
This commit is contained in:
parent
fbc5008259
commit
47479c8799
@ -535,7 +535,6 @@ def stream_chat_message_objects(
|
||||
search_tool: SearchTool | None = None
|
||||
tool_dict: dict[int, list[Tool]] = {} # tool_id to tool
|
||||
for db_tool_model in persona.tools:
|
||||
print(f"TOOL IS {db_tool_model}")
|
||||
# handle in-code tools specially
|
||||
|
||||
if db_tool_model.in_code_tool_id:
|
||||
@ -544,7 +543,6 @@ def stream_chat_message_objects(
|
||||
tool_cls.__name__ == CSVAnalysisTool.__name__
|
||||
and not latest_query_files
|
||||
):
|
||||
print("TOOL CALL")
|
||||
tool_dict[db_tool_model.id] = [CSVAnalysisTool()]
|
||||
|
||||
if (
|
||||
@ -623,8 +621,6 @@ def stream_chat_message_objects(
|
||||
]
|
||||
|
||||
continue
|
||||
else:
|
||||
print("LEAVE")
|
||||
# handle all custom tools
|
||||
if db_tool_model.openapi_schema:
|
||||
tool_dict[db_tool_model.id] = cast(
|
||||
@ -946,5 +942,4 @@ def stream_chat_message(
|
||||
is_connected=is_connected,
|
||||
)
|
||||
for obj in objects:
|
||||
print(obj)
|
||||
yield get_json_line(obj.model_dump())
|
||||
|
@ -47,7 +47,6 @@ from danswer.tools.custom.custom_tool_prompt_builder import (
|
||||
)
|
||||
from danswer.tools.force import filter_tools_for_force_tool_use
|
||||
from danswer.tools.force import ForceUseTool
|
||||
from danswer.tools.graphing.graphing_tool import GraphingTool
|
||||
from danswer.tools.images.image_generation_tool import IMAGE_GENERATION_RESPONSE_ID
|
||||
from danswer.tools.images.image_generation_tool import ImageGenerationResponse
|
||||
from danswer.tools.images.image_generation_tool import ImageGenerationTool
|
||||
@ -246,7 +245,7 @@ class Answer:
|
||||
self.tools, self.force_use_tool
|
||||
)
|
||||
]
|
||||
|
||||
print(final_tool_definitions)
|
||||
for message in self.llm.stream(
|
||||
prompt=prompt,
|
||||
tools=final_tool_definitions if final_tool_definitions else None,
|
||||
@ -537,28 +536,33 @@ class Answer:
|
||||
prompt_builder, final_context_documents
|
||||
)
|
||||
elif tool.name == ImageGenerationTool._NAME:
|
||||
img_urls = []
|
||||
for response in tool_runner.tool_responses():
|
||||
if response.id == IMAGE_GENERATION_RESPONSE_ID:
|
||||
img_generation_response = cast(
|
||||
list[ImageGenerationResponse], response.response
|
||||
)
|
||||
img_urls = [img.url for img in img_generation_response]
|
||||
# img_urls = [img.url for img in img_generation_response]
|
||||
prompt_builder.update_user_prompt(
|
||||
build_image_generation_user_prompt(
|
||||
query=self.question,
|
||||
img_urls=[img.url for img in img_generation_response],
|
||||
)
|
||||
)
|
||||
|
||||
yield response
|
||||
elif tool.name == CSVAnalysisTool._NAME:
|
||||
for response in tool_runner.tool_responses():
|
||||
yield response
|
||||
|
||||
elif tool.name == GraphingTool._NAME:
|
||||
for response in tool_runner.tool_responses():
|
||||
yield response
|
||||
prompt_builder.update_user_prompt(
|
||||
build_image_generation_user_prompt(
|
||||
query=self.question,
|
||||
img_urls=img_urls,
|
||||
)
|
||||
)
|
||||
# elif tool.name == GraphingTool._NAME:
|
||||
# for response in tool_runner.tool_responses():
|
||||
# yield response
|
||||
# prompt_builder.update_user_prompt(
|
||||
# build_image_generation_user_prompt(
|
||||
# query=self.question,
|
||||
# # img_urls=img_urls,
|
||||
# )
|
||||
# )
|
||||
else:
|
||||
prompt_builder.update_user_prompt(
|
||||
HumanMessage(
|
||||
|
@ -56,25 +56,6 @@ Follow Up Input:
|
||||
""".strip()
|
||||
|
||||
|
||||
# system_message = """
|
||||
# You are an AI assistant specialized in creating Python code for generating graphs using matplotlib and Seaborn.
|
||||
# When given a request for a graph, you should generate complete Python code that uses matplotlib
|
||||
# to create the requested graph. The code should:
|
||||
# 1. Import necessary libraries (matplotlib, seaborn, numpy if needed) USE SEARBON
|
||||
# 2. Define the data (you can create sample data that fits the request)
|
||||
# 3. Create the plot using matplotlib and Seaborn
|
||||
# 4. Set appropriate labels, title, and legend
|
||||
# 5. Use plt.figure() to create the figure and assign it to a variable named 'fig'
|
||||
# 6. Do not include plt.show() at the end of the code
|
||||
# 7. Make sure to import things like `plt`
|
||||
|
||||
# Ensure the code is complete and can be executed as-is to generate the graph.
|
||||
# Do not wrap the code in markdown code blocks or use any other formatting.
|
||||
# Simply provide the raw Python code.
|
||||
|
||||
|
||||
# """
|
||||
|
||||
system_message = """
|
||||
You create Python code for graphs using matplotlib. Your code should:
|
||||
Import libraries: matplotlib.pyplot as plt, numpy as np
|
||||
@ -117,13 +98,6 @@ class GraphingTool(Tool):
|
||||
def display_name(self) -> str:
|
||||
return self._DISPLAY_NAME
|
||||
|
||||
@classmethod
|
||||
def create_prompt(cls, message: PreviousMessage) -> str:
|
||||
# TODO improve / iterate
|
||||
print(f"\n\n\n------------\n\n\nCreating a grpah {message.message}")
|
||||
|
||||
return f'I searched for some things! """thigns that I searched for!: {message.message}"""'
|
||||
|
||||
def tool_definition(self) -> dict:
|
||||
return {
|
||||
"type": "function",
|
||||
@ -149,7 +123,7 @@ class GraphingTool(Tool):
|
||||
history: list[PreviousMessage],
|
||||
llm: LLM,
|
||||
) -> bool:
|
||||
return True
|
||||
# return True
|
||||
history_str = "\n".join([f"{m.message}" for m in history])
|
||||
prompt = GRAPHING_TEMPLATE.format(
|
||||
chat_history=history_str,
|
||||
|
1
backend/output/plot_data.json
Normal file
1
backend/output/plot_data.json
Normal file
@ -0,0 +1 @@
|
||||
{"data": [{"x": [0.0, 0.10101010101010101, 0.20202020202020202, 0.30303030303030304, 0.40404040404040403, 0.5050505050505051, 0.6060606060606061, 0.7070707070707071, 0.8080808080808081, 0.9090909090909091, 1.0101010101010102, 1.1111111111111112, 1.2121212121212122, 1.3131313131313131, 1.4141414141414141, 1.5151515151515151, 1.6161616161616161, 1.7171717171717171, 1.8181818181818181, 1.9191919191919191, 2.0202020202020203, 2.121212121212121, 2.2222222222222223, 2.323232323232323, 2.4242424242424243, 2.525252525252525, 2.6262626262626263, 2.727272727272727, 2.8282828282828283, 2.929292929292929, 3.0303030303030303, 3.131313131313131, 3.2323232323232323, 3.3333333333333335, 3.4343434343434343, 3.5353535353535355, 3.6363636363636362, 3.7373737373737375, 3.8383838383838382, 3.9393939393939394, 4.040404040404041, 4.141414141414141, 4.242424242424242, 4.343434343434343, 4.444444444444445, 4.545454545454545, 4.646464646464646, 4.747474747474747, 4.848484848484849, 4.94949494949495, 5.05050505050505, 5.151515151515151, 5.252525252525253, 5.353535353535354, 5.454545454545454, 5.555555555555555, 5.656565656565657, 5.757575757575758, 5.858585858585858, 5.959595959595959, 6.0606060606060606, 6.161616161616162, 6.262626262626262, 6.363636363636363, 6.4646464646464645, 6.565656565656566, 6.666666666666667, 6.767676767676767, 6.8686868686868685, 6.96969696969697, 7.070707070707071, 7.171717171717171, 7.2727272727272725, 7.373737373737374, 7.474747474747475, 7.575757575757575, 7.6767676767676765, 7.777777777777778, 7.878787878787879, 7.979797979797979, 8.080808080808081, 8.181818181818182, 8.282828282828282, 8.383838383838384, 8.484848484848484, 8.585858585858587, 8.686868686868687, 8.787878787878787, 8.88888888888889, 8.98989898989899, 9.09090909090909, 9.191919191919192, 9.292929292929292, 9.393939393939394, 9.494949494949495, 9.595959595959595, 9.696969696969697, 9.797979797979798, 9.8989898989899, 10.0], "y": [0.0, 0.1008384202581046, 0.2006488565226854, 0.2984138044476411, 0.3931366121483298, 0.48385164043793466, 0.5696341069089657, 0.6496095135057065, 0.7229625614794605, 0.7889454628442574, 0.8468855636029834, 0.8961922010299563, 0.9363627251042848, 0.9669876227092996, 0.9877546923600838, 0.9984522269003895, 0.9989711717233568, 0.9893062365143401, 0.9695559491823237, 0.9399216514301312, 0.9007054462029555, 0.8523071179396752, 0.7952200570230491, 0.7300262299764464, 0.6573902466827755, 0.5780525851065732, 0.4928220425889235, 0.40256749066949654, 0.30820901749007684, 0.2107085480771929, 0.11106003812412972, 0.010279341240534697, -0.09060614703340773, -0.19056796287548539, -0.28858705872043244, -0.38366419180611233, -0.47483011082223947, -0.5611554368152017, -0.6417601376193878, -0.7158224992291902, -0.7825875026542022, -0.8413745208608701, -0.8915842573351402, -0.9327048555318336, -0.9643171169287782, -0.9860987744909296, -0.9978277779792126, -0.9993845576124357, -0.9907532430056771, -0.9720218249588334, -0.9433812584459996, -0.9051235159501367, -0.8576386109880517, -0.8014106221689696, -0.7370127583189133, -0.6651015149788224, -0.5864099818472351, -0.5017403693939113, -0.4119558308308628, -0.31797166281061867, -0.22074597455506334, -0.12126992053716677, -0.020557596287260064, 0.08036429967028173, 0.18046693235991093, 0.27872981867755725, 0.37415123057121996, 0.4657584070256517, 0.5526174707464059, 0.6338429484489058, 0.7086067976992182, 0.7761468482835805, 0.8357745720522589, 0.8868821020290788, 0.9289484292312513, 0.9615447140268235, 0.9843386578838236, 0.9970978909438748, 0.9996923408861117, 0.9920955589323228, 0.9743849894755358, 0.9467411805833543, 0.9094459434244625, 0.8628794793817834, 0.8075165041395626, 0.7439214082568444, 0.6727425035622647, 0.5947054140244975, 0.510605678474283, 0.4213006405886069, 0.32770070881349983, 0.23076007532505177, 0.13146698864295842, 0.03083367906114098, -0.07011396040064677, -0.1703468323280965, -0.26884312591038406, -0.3645987336558887, -0.45663748763377376, -0.5440211108893698], "label": "sin(x)", "color": "#1f77b4"}], "title": "Simple Line Graph: sin(x)", "xlabel": "X-axis", "ylabel": "Y-axis"}
|
Loading…
x
Reference in New Issue
Block a user