nashsu / FreeAskInternet

FreeAskInternet is a completely free, PRIVATE and LOCALLY running search aggregator & answer generate using MULTI LLMs, without GPU needed. The user can ask a question and the system will make a multi engine search and combine the search result to LLM and generate the answer based on search results. It's all FREE to use.
Apache License 2.0
8.41k stars 875 forks source link

怎么设置自定义模型 #64

Closed DivvSpace closed 4 months ago

DivvSpace commented 4 months ago

截屏2024-04-1 如果设置了相关链接,是哪里出了问题

aotsukiqx commented 4 months ago

看了看docker日志没把我愁死,query=fasdf&model=gpt3.5&ask_type=search&model_token=" ",第一个问题,没有使用配置的自定义模型名称(但是确实改了base url),第二个问题压根就没用设置的token,也就是除非你本地模型不做token验证才能用。

huawuhen commented 4 months ago

同样的问题,

DivvSpace commented 4 months ago

开个Discord,一块研究研究

pirately commented 4 months ago

可以直接修改free_ask_internet.py文件,调用ollama等自定义的。再通过第三方,比如nextchat调用本项目的端口就可以。或者把这个项目的接口加入one-api,当作单独的search模型调用。

huawuhen commented 4 months ago

可以直接修改free_ask_internet.py文件,调用ollama等自定义的。再通过第三方,比如nextchat调用本项目的端口就可以。或者把这个项目的接口加入one-api,当作单独的search模型调用。

关键是one-api无法接入

pirately commented 4 months ago

可以直接修改free_ask_internet.py文件,调用ollama等自定义的。再通过第三方,比如nextchat调用本项目的端口就可以。或者把这个项目的接口加入one-api,当作单独的search模型调用。

关键是one-api无法接入

可以的

one-api search模型

利用one-api自定义search模型

nextchat选择search模型

nextchat客户端选择search模型

利用search回答

用search模型回答

2451965602 commented 4 months ago

可以直接修改free_ask_internet.py文件,调用ollama等自定义的。再通过第三方,比如nextchat调用本项目的端口就可以。或者把这个项目的接口加入one-api,当作单独的search模型调用。

关键是one-api无法接入

可以的

one-api search模型

利用one-api自定义search模型

nextchat选择search模型

nextchat客户端选择search模型

利用search回答

用search模型回答

用oneapi接入时报错,直接在free_ask_internet_ui里调用正常

model='search' messages=[ChatMessage(role='user', content='霍尔')] temperature=0.5 top_p=1.0 max_length=None stream=True
2024-04-14T12:19:39.928153497Z INFO:     172.17.0.2:53486 - "POST /v1/chat/completions?path=v1&path=chat&path=completions HTTP/1.1" 200 OK
2024-04-14T12:19:42.246322601Z ERROR:    Exception in ASGI application
2024-04-14T12:19:42.246345855Z Traceback (most recent call last):
2024-04-14T12:19:42.246348700Z   File "/usr/local/lib/python3.9/site-packages/sse_starlette/sse.py", line 281, in __call__
2024-04-14T12:19:42.246350644Z     await wrap(partial(self.listen_for_disconnect, receive))
2024-04-14T12:19:42.246352237Z   File "/usr/local/lib/python3.9/site-packages/sse_starlette/sse.py", line 270, in wrap
2024-04-14T12:19:42.246353910Z     await func()
2024-04-14T12:19:42.246355764Z   File "/usr/local/lib/python3.9/site-packages/sse_starlette/sse.py", line 221, in listen_for_disconnect
2024-04-14T12:19:42.246357467Z     message = await receive()
2024-04-14T12:19:42.246359040Z   File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 535, in receive
2024-04-14T12:19:42.246360563Z     await self.message_event.wait()
2024-04-14T12:19:42.246362025Z   File "/usr/local/lib/python3.9/asyncio/locks.py", line 226, in wait
2024-04-14T12:19:42.246384008Z     await fut
2024-04-14T12:19:42.246386052Z asyncio.exceptions.CancelledError: Cancelled by cancel scope 7fd034609e20
2024-04-14T12:19:42.246387675Z 
2024-04-14T12:19:42.246389338Z During handling of the above exception, another exception occurred:
2024-04-14T12:19:42.246390851Z 
2024-04-14T12:19:42.246392423Z   + Exception Group Traceback (most recent call last):
2024-04-14T12:19:42.246393876Z   |   File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
2024-04-14T12:19:42.246395479Z   |     result = await app(  # type: ignore[func-returns-value]
2024-04-14T12:19:42.246396932Z   |   File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
2024-04-14T12:19:42.246398465Z   |     return await self.app(scope, receive, send)
2024-04-14T12:19:42.246399908Z   |   File "/usr/local/lib/python3.9/site-packages/fastapi/applications.py", line 1054, in __call__
2024-04-14T12:19:42.246401451Z   |     await super().__call__(scope, receive, send)
2024-04-14T12:19:42.246403034Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/applications.py", line 123, in __call__
2024-04-14T12:19:42.246404597Z   |     await self.middleware_stack(scope, receive, send)
2024-04-14T12:19:42.246406019Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 186, in __call__
2024-04-14T12:19:42.246407552Z   |     raise exc
2024-04-14T12:19:42.246408945Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 164, in __call__
2024-04-14T12:19:42.246410457Z   |     await self.app(scope, receive, _send)
2024-04-14T12:19:42.246411900Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 85, in __call__
2024-04-14T12:19:42.246413483Z   |     await self.app(scope, receive, send)
2024-04-14T12:19:42.246415647Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
2024-04-14T12:19:42.246417210Z   |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
2024-04-14T12:19:42.246418693Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
2024-04-14T12:19:42.246420236Z   |     raise exc
2024-04-14T12:19:42.246421689Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
2024-04-14T12:19:42.246423642Z   |     await app(scope, receive, sender)
2024-04-14T12:19:42.246425175Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 756, in __call__
2024-04-14T12:19:42.246426688Z   |     await self.middleware_stack(scope, receive, send)
2024-04-14T12:19:42.246428341Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 776, in app
2024-04-14T12:19:42.246432679Z   |     await route.handle(scope, receive, send)
2024-04-14T12:19:42.246434272Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 297, in handle
2024-04-14T12:19:42.246435945Z   |     await self.app(scope, receive, send)
2024-04-14T12:19:42.246437589Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 77, in app
2024-04-14T12:19:42.246439092Z   |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
2024-04-14T12:19:42.246440555Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
2024-04-14T12:19:42.246442088Z   |     raise exc
2024-04-14T12:19:42.246443631Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
2024-04-14T12:19:42.246454611Z   |     await app(scope, receive, sender)
2024-04-14T12:19:42.246456384Z   |   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 75, in app
2024-04-14T12:19:42.246457907Z   |     await response(scope, receive, send)
2024-04-14T12:19:42.246459340Z   |   File "/usr/local/lib/python3.9/site-packages/sse_starlette/sse.py", line 281, in __call__
2024-04-14T12:19:42.246460983Z   |     await wrap(partial(self.listen_for_disconnect, receive))
2024-04-14T12:19:42.246462426Z   |   File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 678, in __aexit__
2024-04-14T12:19:42.246463979Z   |     raise BaseExceptionGroup(
2024-04-14T12:19:42.246465412Z   | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
2024-04-14T12:19:42.246466874Z   +-+---------------- 1 ----------------
2024-04-14T12:19:42.246468317Z     | Traceback (most recent call last):
2024-04-14T12:19:42.246469760Z     |   File "/usr/local/lib/python3.9/site-packages/sse_starlette/sse.py", line 270, in wrap
2024-04-14T12:19:42.246471292Z     |     await func()
2024-04-14T12:19:42.246473086Z     |   File "/usr/local/lib/python3.9/site-packages/sse_starlette/sse.py", line 251, in stream_response
2024-04-14T12:19:42.246474639Z     |     async for data in self.body_iterator:
2024-04-14T12:19:42.246476162Z     |   File "/usr/local/lib/python3.9/site-packages/starlette/concurrency.py", line 65, in iterate_in_threadpool
2024-04-14T12:19:42.246477724Z     |     yield await anyio.to_thread.run_sync(_next, as_iterator)
2024-04-14T12:19:42.246479187Z     |   File "/usr/local/lib/python3.9/site-packages/anyio/to_thread.py", line 56, in run_sync
2024-04-14T12:19:42.246480720Z     |     return await get_async_backend().run_sync_in_worker_thread(
2024-04-14T12:19:42.246482293Z     |   File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 2144, in run_sync_in_worker_thread
2024-04-14T12:19:42.246483836Z     |     return await future
2024-04-14T12:19:42.246486070Z     |   File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 851, in run
2024-04-14T12:19:42.246492543Z     |     result = context.run(func, *args)
2024-04-14T12:19:42.246495790Z     |   File "/usr/local/lib/python3.9/site-packages/starlette/concurrency.py", line 54, in _next
2024-04-14T12:19:42.246499246Z     |     return next(iterator)
2024-04-14T12:19:42.246502452Z     |   File "/app/server.py", line 152, in predict
2024-04-14T12:19:42.246505558Z     |     for token in free_ask_internet.ask_internet(query=query):
2024-04-14T12:19:42.246508594Z     |   File "/app/free_ask_internet.py", line 204, in ask_internet
2024-04-14T12:19:42.246511669Z     |     prompt = gen_prompt(query,content_list,context_length_limit=6000,debug=debug)
2024-04-14T12:19:42.246514785Z     |   File "/app/free_ask_internet.py", line 108, in gen_prompt
2024-04-14T12:19:42.246517741Z     |     ref_content = [ item.get("content") for item in content_list]
2024-04-14T12:19:42.246534422Z     |   File "/app/free_ask_internet.py", line 108, in <listcomp>
2024-04-14T12:19:42.246538580Z     |     ref_content = [ item.get("content") for item in content_list]
2024-04-14T12:19:42.246540643Z     | AttributeError: 'list' object has no attribute 'get'
2024-04-14T12:19:42.246542277Z     +------------------------------------
DivvSpace commented 4 months ago

怎么设置页面都不一样😂

pirately commented 4 months ago

可以直接修改free_ask_internet.py文件,调用ollama等自定义的。再通过第三方,比如nextchat调用本项目的端口就可以。或者把这个项目的接口加入one-api,当作单独的search模型调用。

关键是one-api无法接入

可以的

用oneapi接入时报错,直接在free_ask_internet_ui里调用正常

free_ask_internet.py文件中的 219行,改content_list = search_web_ref(query,debug=debug)conv_links, content_list = search_web_ref(query,debug=debug)。直接用python server.py在本地试。searxng模型,还有其他gpt或者glm模型用本地已经搭建好的,也就是38行和172行要改成本地的

pirately commented 4 months ago

怎么设置页面都不一样😂

我没有用freeaskinternet ui这个,我是把本项目当api调用的。

huawuhen commented 4 months ago

我知道问题出在哪里了,问了作者,他的接口不是标准的openai-api,需要你的one-api接口地址后面加个/v1/

DivvSpace commented 4 months ago

我知道问题出在哪里了,问了作者,他的接口不是标准的openai-api,需要你的one-api接口地址后面加个/v1/

一针见血的,有用的👍