-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add multiple formats to tools (#3041)
- Loading branch information
Showing
10 changed files
with
220 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
backend/danswer/tools/tool_implementations/custom/prompt.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from langchain_core.messages import HumanMessage | ||
|
||
from danswer.file_store.models import ChatFileType | ||
from danswer.file_store.models import InMemoryChatFile | ||
from danswer.llm.utils import build_content_with_imgs | ||
|
||
|
||
CUSTOM_IMG_GENERATION_SUMMARY_PROMPT = """ | ||
You have just created the attached {file_type} file in response to the following query: "{query}". | ||
Can you please summarize it in a sentence or two? Do NOT include image urls or bulleted lists. | ||
""" | ||
|
||
|
||
def build_custom_image_generation_user_prompt( | ||
query: str, file_type: ChatFileType, files: list[InMemoryChatFile] | None = None | ||
) -> HumanMessage: | ||
return HumanMessage( | ||
content=build_content_with_imgs( | ||
message=CUSTOM_IMG_GENERATION_SUMMARY_PROMPT.format( | ||
query=query, file_type=file_type.value | ||
).strip(), | ||
files=files, | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.