-
Notifications
You must be signed in to change notification settings - Fork 258
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Language
Javascript/Typescript
Version
latest - 1.7.3
Description
Using the StreamingResponse with .setCitation(), I have added an array of citations that are all formatted like so
return {
title: doc.title || '',
url: doc.url || '',
content: truncLong(doc.text || ''),
filepath: '',
};
The citations appear:
However the URLs do not work, and it also seems like the title and content fields might be misplaced?
Reproduction Steps
1. Inside a message handler `app.activity(ActivityTypes.Message,`
2. Initialize a `let streamer = new StreamingResponse(context);`
3.
Format citations and set them on the streamer like so:
let stream_citations: Citation[] = docs.map((doc) => {
return {
title: doc.title || '',
url: doc.url || '',
content: truncLong(doc.text || ''),
filepath: '',
};
});
streamer.setCitations(stream_citations);Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
sayali-MSFT commentedon Feb 28, 2025
@tianjing-li ,Thank you for your inquiry about your Teams app development issue! To assist you better, could you please provide the following details?
Documentation Links: Any specific documentation you followed that relates to your problem.
This information will help us better understand the situation and provide a more accurate response.
tianjing-li commentedon Feb 28, 2025
@sayali-MSFT I've looked at the docs for the StreamingResponse class directly. Here there is a
setCitations()method which I've called with correctly formattedCitationobjectstianjing-li commentedon Feb 28, 2025
When using
context.sendActivity(..)to send a message directly with citations attached this seems to work for the URL, however I need citations to work for my streamed response. Let me know if my approach withsetCitations()is not correct, otherwise there's likely a bug.lilyydu commentedon Mar 1, 2025
Hi @tianjing-li , what are the URLs linking to right now?
sayali-MSFT commentedon Mar 3, 2025
@tianjing-li , It looks like you're trying to use the StreamingResponse class to send a message with citations. Based on your description, the URLs in the citations may not be working, and the title and content fields might be misplaced.
To resolve this, please ensure the following:
Additionally, could you please share the information requested by @lilyydu?
tianjing-li commentedon Mar 3, 2025
Hi @lilyydu, I've tested them with links to regular wikipedia pages, here's an example command I used to test a stream with citations:
I also have working RAG functionality that generates actual citations, but the general logic is the same. Neither of them seem to open the URL.
Just in case, here's my package versions:
lilyydu commentedon Mar 4, 2025
Based on the screenshot above, is the message being represented as the URL instead?
And can you confirm that the message being returned is correct as well?
tianjing-li commentedon Mar 4, 2025
@lilyydu I believe I found the error, if you look at the source code of
setCitations(), you'll see actually that you're parsing theCitationobject in the parameter but not using theurlproperty when constructing the newClientCitationobject.See: https://github.com/microsoft/teams-ai/blob/main/js/packages/teams-ai/src/StreamingResponse.ts#L158
tianjing-li commentedon Mar 4, 2025
Changing the method to
Seems to work
corinagum commentedon Mar 13, 2025
@tianjing-li This was an intentional decision at the time of implementation because the citation urls provided by Azure inevitably linked to a 404. After a lot of discussion internally, we decided that linking to a 404 would confuse people more than leaving it intentionally blank, since for a user to be able to view anything in the citation the develper would need to provide a public link to the file being cited.
However it looks like that's been resolved, it looks like we can update both streaming and non-streaming in all three languages to automatically link the
citation.url:)lilyydu commentedon Mar 13, 2025
@tianjing-li Would you be able to file this python fix in a PR for both the streaming and non-streaming cases?
The other spot would be here-
https://github.com/microsoft/teams-ai/blob/5b3d35c832de200ad374da7a0a1819f73bf795eb/python/packages/ai/teams/ai/ai.py#L302-L311
tianjing-li commentedon Jul 8, 2025
@lilyydu is this still a need? I likely have bandwidth this week to make a PR
lilyydu commentedon Jul 8, 2025
Hi @tianjing-li,
Yup that would be greatly appreciated!
tianjing-li commentedon Jul 10, 2025
@lilyydu Please take a look at #2528
[repo] fix: add url to ClientCitations (#2528)