-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
๐ style: add build-in web search support for Wenxin & Hunyuan #6617
Conversation
@hezhijie0327 is attempting to deploy a commit to the LobeChat Desktop Team on Vercel. A member of the Team first needs to authorize it. |
๐ @hezhijie0327 Thank you for raising your pull request and contributing to our Community |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6617 +/- ##
==========================================
- Coverage 91.56% 91.56% -0.01%
==========================================
Files 716 716
Lines 67169 67236 +67
Branches 3035 3242 +207
==========================================
+ Hits 61506 61567 +61
- Misses 5663 5669 +6
Flags with carried forward coverage won't be shown. Click here to find out more. โ View full report in Codecov by Sentry. |
่ฟไธช่พๅบๆจกๅผๅบ่ฏฅๅฐฑๅ pplx ็ไธๆ ท๏ผๅ่ฟๆฎต้ป่พ็ฑปไผผ๏ผ lobe-chat/src/libs/agent-runtime/utils/streams/openai.ts Lines 129 to 147 in a76d2bf
ๅช้่ฆๅไธชๅคๆญๅจ่ฟ็ป chunk ้ๆฏๅฆๅ
ๅซๆ [
{ data: { citations }, id: chunk.id, type: 'grounding' },
{ data: content, id: chunk.id, type: 'text' },
] |
@arvinxx ๅทฒ้้ ๏ผ้กบๅธฆๆ Hunyuan ็ๅผ็จไนไธ่ตทๆๆไบ |
@arvinxx has been adapted, and Hunyuan's quotation was also removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
้่ฆๅ่ pplx ไธๆ ท๏ผ่กฅไธๅฏนๅบ็ provider ไธ็ๅๆต๏ผ
lobe-chat/src/libs/agent-runtime/perplexity/index.test.ts
Lines 67 to 247 in a76d2bf
it('should with search citations', async () => { | |
const data = [ | |
{ | |
id: '506d64fb-e7f2-4d94-b80f-158369e9446d', | |
model: 'sonar-pro', | |
created: 1739896615, | |
object: 'chat.completion.chunk', | |
choices: [ | |
{ | |
finish_reason: null, | |
index: 0, | |
delta: { | |
refusal: null, | |
content: '<think>', | |
role: 'assistant', | |
function_call: null, | |
tool_calls: null, | |
audio: null, | |
}, | |
logprobs: null, | |
}, | |
], | |
stream_options: null, | |
citations: null, | |
}, | |
{ | |
id: '506d64fb-e7f2-4d94-b80f-158369e9446d', | |
model: 'sonar-pro', | |
created: 1739896615, | |
usage: { | |
prompt_tokens: 4, | |
completion_tokens: 3, | |
total_tokens: 7, | |
citation_tokens: 2217, | |
num_search_queries: 1, | |
}, | |
citations: [ | |
'https://www.weather.com.cn/weather/101210101.shtml', | |
'https://tianqi.moji.com/weather/china/zhejiang/hangzhou', | |
'https://weather.cma.cn/web/weather/58457.html', | |
'https://tianqi.so.com/weather/101210101', | |
'https://www.accuweather.com/zh/cn/hangzhou/106832/weather-forecast/106832', | |
'https://www.hzqx.com', | |
'https://www.hzqx.com/pc/hztq/', | |
], | |
object: 'chat.completion', | |
choices: [ | |
{ | |
index: 0, | |
finish_reason: null, | |
message: { | |
role: 'assistant', | |
content: 'ๆญๅทไป', | |
}, | |
delta: { | |
role: 'assist', | |
content: 'ๆญๅทไป', | |
}, | |
}, | |
], | |
}, | |
{ | |
id: '506d64fb-e7f2-4d94-b80f-158369e9446d', | |
model: 'sonar-pro', | |
created: 1739896615, | |
usage: { | |
prompt_tokens: 4, | |
completion_tokens: 9, | |
total_tokens: 13, | |
citation_tokens: 2217, | |
num_search_queries: 1, | |
}, | |
citations: [ | |
'https://www.weather.com.cn/weather/101210101.shtml', | |
'https://tianqi.moji.com/weather/china/zhejiang/hangzhou', | |
'https://weather.cma.cn/web/weather/58457.html', | |
'https://tianqi.so.com/weather/101210101', | |
'https://www.accuweather.com/zh/cn/hangzhou/106832/weather-forecast/106832', | |
'https://www.hzqx.com', | |
'https://www.hzqx.com/pc/hztq/', | |
], | |
object: 'chat.completion', | |
choices: [ | |
{ | |
index: 0, | |
finish_reason: null, | |
message: { | |
role: 'assistant', | |
content: 'ๆญๅทไปๅคฉๅๆชๆฅๅ ๅคฉ็', | |
}, | |
delta: { | |
role: 'assistant', | |
content: 'ๅคฉๅๆชๆฅๅ ๅคฉ็', | |
}, | |
}, | |
], | |
}, | |
{ | |
id: '506d64fb-e7f2-4d94-b80f-158369e9446d', | |
model: 'sonar-pro', | |
created: 1739896615, | |
usage: { | |
prompt_tokens: 4, | |
completion_tokens: 14, | |
total_tokens: 18, | |
citation_tokens: 2217, | |
num_search_queries: 1, | |
}, | |
citations: [ | |
'https://www.weather.com.cn/weather/101210101.shtml', | |
'https://tianqi.moji.com/weather/china/zhejiang/hangzhou', | |
'https://weather.cma.cn/web/weather/58457.html', | |
'https://tianqi.so.com/weather/101210101', | |
'https://www.accuweather.com/zh/cn/hangzhou/106832/weather-forecast/106832', | |
'https://www.hzqx.com', | |
'https://www.hzqx.com/pc/hztq/', | |
], | |
object: 'chat.completion', | |
choices: [ | |
{ | |
index: 0, | |
finish_reason: null, | |
message: { | |
role: 'assistant', | |
content: 'ๆญๅทไปๅคฉๅๆชๆฅๅ ๅคฉ็ๅคฉๆฐ้ขๆฅๅฆ', | |
}, | |
}, | |
], | |
}, | |
]; | |
const mockStream = new ReadableStream({ | |
start(controller) { | |
data.forEach((chunk) => { | |
controller.enqueue(chunk); | |
}); | |
controller.close(); | |
}, | |
}); | |
vi.spyOn(instance['client'].chat.completions, 'create').mockResolvedValue(mockStream as any); | |
const result = await instance.chat({ | |
messages: [{ content: 'Hello', role: 'user' }], | |
model: 'mistralai/mistral-7b-instruct:free', | |
temperature: 0, | |
}); | |
const decoder = new TextDecoder(); | |
const reader = result.body!.getReader(); | |
const stream: string[] = []; | |
while (true) { | |
const { value, done } = await reader.read(); | |
if (done) break; | |
stream.push(decoder.decode(value)); | |
} | |
expect(stream).toEqual( | |
[ | |
'id: 506d64fb-e7f2-4d94-b80f-158369e9446d', | |
'event: text', | |
'data: "<think>"\n', | |
'id: 506d64fb-e7f2-4d94-b80f-158369e9446d', | |
'event: grounding', | |
'data: {"citations":[{"title":"https://www.weather.com.cn/weather/101210101.shtml","url":"https://www.weather.com.cn/weather/101210101.shtml"},{"title":"https://tianqi.moji.com/weather/china/zhejiang/hangzhou","url":"https://tianqi.moji.com/weather/china/zhejiang/hangzhou"},{"title":"https://weather.cma.cn/web/weather/58457.html","url":"https://weather.cma.cn/web/weather/58457.html"},{"title":"https://tianqi.so.com/weather/101210101","url":"https://tianqi.so.com/weather/101210101"},{"title":"https://www.accuweather.com/zh/cn/hangzhou/106832/weather-forecast/106832","url":"https://www.accuweather.com/zh/cn/hangzhou/106832/weather-forecast/106832"},{"title":"https://www.hzqx.com","url":"https://www.hzqx.com"},{"title":"https://www.hzqx.com/pc/hztq/","url":"https://www.hzqx.com/pc/hztq/"}]}\n', | |
'id: 506d64fb-e7f2-4d94-b80f-158369e9446d', | |
'event: text', | |
'data: "ๆญๅทไป"\n', | |
'id: 506d64fb-e7f2-4d94-b80f-158369e9446d', | |
'event: text', | |
'data: "ๅคฉๅๆชๆฅๅ ๅคฉ็"\n', | |
'id: 506d64fb-e7f2-4d94-b80f-158369e9446d', | |
'event: data', | |
'data: {"id":"506d64fb-e7f2-4d94-b80f-158369e9446d","index":0}\n', | |
].map((line) => `${line}\n`), | |
); | |
expect((await reader.read()).done).toBe(true); | |
}); |
ๅๆตๆไบ |
Single test |
่ฏถ ๅชๆนไบ
|
|
@arvinxx ไฟฎๅฅฝไบ |
@arvinxx Fixed |
The latest updates on your projects. Learn more about Vercel for Git โ๏ธ
|
โค๏ธ Great PR @hezhijie0327 โค๏ธ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
### [Version 1.68.2](v1.68.1...v1.68.2) <sup>Released on **2025-03-03**</sup> #### ๐ Styles - **misc**: Add build-in web search support for Wenxin & Hunyuan. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Styles * **misc**: Add build-in web search support for Wenxin & Hunyuan, closes [#6617](#6617) ([dfd1f09](dfd1f09)) </details> <div align="right"> [](#readme-top) </div>
๐ This PR is included in version 1.68.2 ๐ The release is available on: Your semantic-release bot ๐ฆ๐ |
## [Version 1.109.0](v1.108.1...v1.109.0) <sup>Released on **2025-03-03**</sup> #### โจ Features - **misc**: Add new model provider PPIO. #### ๐ Bug Fixes - **misc**: Fix page crash with crawler error, fix search web-browsing display bug. #### ๐ Styles - **misc**: Add build-in web search support for Wenxin & Hunyuan. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's improved * **misc**: Add new model provider PPIO, closes [lobehub#6133](https://github.com/bentwnghk/lobe-chat/issues/6133) ([23a3fda](23a3fda)) #### What's fixed * **misc**: Fix page crash with crawler error, closes [lobehub#6662](https://github.com/bentwnghk/lobe-chat/issues/6662) ([0c24251](0c24251)) * **misc**: Fix search web-browsing display bug, closes [lobehub#6653](https://github.com/bentwnghk/lobe-chat/issues/6653) ([f472643](f472643)) #### Styles * **misc**: Add build-in web search support for Wenxin & Hunyuan, closes [lobehub#6617](https://github.com/bentwnghk/lobe-chat/issues/6617) ([dfd1f09](dfd1f09)) </details> <div align="right"> [](#readme-top) </div>
โฆb#6617) * โจ feat: add build-in web search support for Wenxin * ๐ fix: fix web_search calling issue * โจ feat: add support wenxin `search_results` stream * โจ feat: add `search_info` stream support for Hunyuan * ๐จ chore: minor logic * ๐จ chore: add unit test * ๐ fix: try to fix ci error * ๐ fix: fix ci error
### [Version 1.68.2](lobehub/lobe-chat@v1.68.1...v1.68.2) <sup>Released on **2025-03-03**</sup> #### ๐ Styles - **misc**: Add build-in web search support for Wenxin & Hunyuan. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Styles * **misc**: Add build-in web search support for Wenxin & Hunyuan, closes [lobehub#6617](lobehub#6617) ([dfd1f09](lobehub@dfd1f09)) </details> <div align="right"> [](#readme-top) </div>
๐ป ๅๆด็ฑปๅ | Change Type
๐ ๅๆด่ฏดๆ | Description of Change
Note:
enable_trace
ๅ๏ผ Wenxin ๆตๅคด้จไผๅๅ ฅsearch_results
ไฟกๆฏ๏ผ็ไธๅ็ปญๅฆไฝ้้ ๅทฒ้้ search_info
ๅ๏ผHunyuan ๆตไผๅจๆฏไธไธช Chunk ไธญๅผๅ ฅsearch_info.search_results
ไฟกๆฏ๐ ่กฅๅ ไฟกๆฏ | Additional Information
#6475 (comment)
ref: https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Fm2vrveyu
ref: https://console.bce.baidu.com/support/?timestamp=1740848928614#/api?product=QIANFAN&project=%E5%8D%83%E5%B8%86ModelBuilder&parent=%E5%AF%B9%E8%AF%9DChat%20V2&api=v2%2Fchat%2Fcompletions&method=post