Skip to content

Commit

Permalink
fix file url
Browse files Browse the repository at this point in the history
  • Loading branch information
willydouhard committed Dec 19, 2023
1 parent b50da84 commit ebfb37d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/chainlit/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,12 @@ async def create_element(self, element: "Element"):
"page": getattr(element, "page", None),
}

if not element.for_id:
return

await self.client.api.create_attachment(
thread_id=element.thread_id,
step_id=element.for_id or "",
step_id=element.for_id,
mime=element.mime,
name=element.name,
url=element.url,
Expand Down
3 changes: 3 additions & 0 deletions libs/react-client/src/api/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ export class ChainlitAPI extends APIBase {
getElementUrl(id: string, sessionId: string, accessToken?: string) {
let queryParams = `?session_id=${sessionId}`;
if (accessToken) {
if (accessToken.startsWith('Bearer ')) {
accessToken = accessToken.slice(7);
}
queryParams += `&token=${accessToken}`;
}
return this.buildEndpoint(`/project/file/${id}${queryParams}`);
Expand Down

0 comments on commit ebfb37d

Please sign in to comment.