-
Notifications
You must be signed in to change notification settings - Fork 189
Enhance data type #378
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
Enhance data type #378
Changes from all commits
7dcbf2f
1e2502a
e12bd29
1cef23c
5bd3591
c8a9472
5fd25f6
a4d3d36
6efadd4
3e82be7
393a926
9602c6c
985cb26
9a4c0a3
2efc727
249edf5
22cd958
30e408b
94b338a
6bb7a30
bbf321f
852e6ec
5ae6b57
c64e2ba
36cdb1e
e0921fe
a3c1c55
bae12e6
7d9dee2
3b91e7b
954113e
624aea7
788fab0
0f56092
051b3cf
4f92ce2
db025d9
c5a381f
f825a8c
8b8afa0
659d0c7
0655a4e
9eb8468
c4e2325
7dd9c86
3a82df0
af83b50
a8c819b
f84db97
e4748df
98dc945
48dcc51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-llama": patch | ||
--- | ||
|
||
Simplify and unify handling file uploads |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,17 +3,13 @@ import { MessageContent, MessageContentDetail } from "llamaindex"; | |
|
||
export type DocumentFileType = "csv" | "pdf" | "txt" | "docx"; | ||
|
||
export type UploadedFileMeta = { | ||
export type DocumentFile = { | ||
id: string; | ||
leehuwuj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: string; | ||
url?: string; | ||
refs?: string[]; | ||
}; | ||
|
||
export type DocumentFile = { | ||
type: DocumentFileType; | ||
size: number; | ||
type: string; | ||
url: string; | ||
metadata: UploadedFileMeta; | ||
refs?: string[]; | ||
Comment on lines
+6
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Inconsistency Found: The TypeScript Affected files:
🔗 Analysis chainStreamlined The To ensure consistency across languages, please verify if the If there are discrepancies, consider aligning the implementations or documenting the reason for the difference. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for DocumentFile or similar types in Python files
rg --type python -i "class\s+(DocumentFile|UploadedFile|FileMetadata)"
Length of output: 103 Script: #!/bin/bash
# Search for DocumentFile or similar types in Python files
rg -g "*.py" -i "class\s+(DocumentFile|UploadedFile|FileMetadata)"
Length of output: 343 |
||
}; | ||
|
||
type Annotation = { | ||
|
@@ -30,7 +26,7 @@ export function isValidMessages(messages: Message[]): boolean { | |
export function retrieveDocumentIds(messages: Message[]): string[] { | ||
// retrieve document Ids from the annotations of all messages (if any) | ||
const documentFiles = retrieveDocumentFiles(messages); | ||
return documentFiles.map((file) => file.metadata?.refs || []).flat(); | ||
return documentFiles.map((file) => file.refs || []).flat(); | ||
} | ||
|
||
export function retrieveDocumentFiles(messages: Message[]): DocumentFile[] { | ||
|
@@ -63,16 +59,15 @@ export function retrieveMessageContent(messages: Message[]): MessageContent { | |
} | ||
|
||
function getFileContent(file: DocumentFile): string { | ||
const fileMetadata = file.metadata; | ||
let defaultContent = `=====File: ${fileMetadata.name}=====\n`; | ||
let defaultContent = `=====File: ${file.name}=====\n`; | ||
// Include file URL if it's available | ||
const urlPrefix = process.env.FILESERVER_URL_PREFIX; | ||
let urlContent = ""; | ||
if (urlPrefix) { | ||
if (fileMetadata.url) { | ||
urlContent = `File URL: ${fileMetadata.url}\n`; | ||
if (file.url) { | ||
urlContent = `File URL: ${file.url}\n`; | ||
} else { | ||
urlContent = `File URL (instruction: do not update this file URL yourself): ${urlPrefix}/output/uploaded/${fileMetadata.name}\n`; | ||
urlContent = `File URL (instruction: do not update this file URL yourself): ${urlPrefix}/output/uploaded/${file.name}\n`; | ||
} | ||
} else { | ||
console.warn( | ||
|
@@ -82,11 +77,11 @@ function getFileContent(file: DocumentFile): string { | |
defaultContent += urlContent; | ||
|
||
// Include document IDs if it's available | ||
if (fileMetadata.refs) { | ||
defaultContent += `Document IDs: ${fileMetadata.refs}\n`; | ||
if (file.refs) { | ||
defaultContent += `Document IDs: ${file.refs}\n`; | ||
} | ||
// Include sandbox file paths | ||
const sandboxFilePath = `/tmp/${fileMetadata.name}`; | ||
const sandboxFilePath = `/tmp/${file.name}`; | ||
defaultContent += `Sandbox file path (instruction: only use sandbox path for artifact or code interpreter tool): ${sandboxFilePath}\n`; | ||
|
||
return defaultContent; | ||
|
Uh oh!
There was an error while loading. Please reload this page.