Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web search support? #28

Open
littleblack111 opened this issue May 26, 2024 · 1 comment
Open

Web search support? #28

littleblack111 opened this issue May 26, 2024 · 1 comment

Comments

@littleblack111
Copy link
Contributor

Will this be added? reffrence: https://github.com/zhuozhiyongde/Unlocking-Raycast-With-Surge/blob/main/app/main.py

I tried to add it my self, but after adding it, gpt will keep returning: count_tools_token_fail: json: cannot unmarshal array into Go value of type dto.OpenAITools (request id: 20240527010538565210467sNOZG6wQ)

code:
from app.serp import tool_serp(serp.py is from https://github.com/zhuozhiyongde/Unlocking-Raycast-With-Surge/blob/main/app/functions/serp.py)
...
tools.append(self.__build_openai_function_img_tool(raycast_data))
tools.append(self.__build_web_search_tool())
async for i in self.__warp_chat(
...

...
def __build_web_search_tool(self):
tools = {
"serp": {
"description": "Search Engine Results Page",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The search query to be used",
}
},
},
# 后面的字段为附属字段,在调用 OpenAI 时会移除
"handler": tool_serp,
"notification": 'data: {"notification":"Searching in Google...","notification_type":"tool_used","text":""}\n\n',
"extra_messages": [
{
"role": "system",
"content": "It is possible to summarize the information from the above, but please note that if you use relevant information in your answer, please mark the citation as strictly 'Source', and note that the first bracket must be the hard-coded English "Source "in the first parenthesis, which is relevant for subsequent rendering. You don't have to use markdown's markup syntax.",
}
],
"required_environ": ["APYHUB_API_KEY"],
},
}
format_tools = []
for tool in tools:
if "required_environ" in tools[tool]:
if any(
[not os.environ.get(env) for env in tools[tool]["required_environ"]]
):
continue
format_tools.append(
{
"type": "function",
"function": {
"name": tool,
"description": tools[tool]["description"],
"parameters": tools[tool]["parameters"],
},
}
)

    return format_tools

...
from the OpenAIChatBot class

please implement this feature, hope the code helps

@littleblack111
Copy link
Contributor Author

@yufeikang pls consider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant