Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Create Llama
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
Create Llama
Commits
7e033091
Commit
7e033091
authored
4 days ago
by
leehuwuj
Browse files
Options
Downloads
Patches
Plain Diff
update UI for TS
parent
1edc16be
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
templates/types/streaming/nextjs/app/components/ui/chat/tools/query-index.tsx
+45
-37
45 additions, 37 deletions
...aming/nextjs/app/components/ui/chat/tools/query-index.tsx
with
45 additions
and
37 deletions
templates/types/streaming/nextjs/app/components/ui/chat/tools/query-index.tsx
+
45
−
37
View file @
7e033091
...
...
@@ -29,44 +29,52 @@ const TypeScriptSchema = z.object({
query
:
z
.
string
(),
}),
toolId
:
z
.
string
(),
toolOutput
:
z
.
object
({
id
:
z
.
string
(),
result
:
z
.
string
(),
isError
:
z
.
boolean
(),
}).
optional
(),
toolOutput
:
z
.
object
({
id
:
z
.
string
(),
result
:
z
.
string
(),
isError
:
z
.
boolean
(),
})
.
optional
(),
returnDirect
:
z
.
boolean
(),
});
const
PythonSchema
=
z
.
object
({
tool_name
:
z
.
union
([
z
.
literal
(
"
query_index
"
),
z
.
literal
(
"
query_engine
"
)]),
tool_kwargs
:
z
.
object
({
input
:
z
.
string
(),
}),
tool_id
:
z
.
string
(),
tool_output
:
z
.
object
({
content
:
z
.
string
(),
tool_name
:
z
.
string
(),
raw_output
:
z
.
object
({
source_nodes
:
z
.
array
(
z
.
any
()),
const
PythonSchema
=
z
.
object
({
tool_name
:
z
.
union
([
z
.
literal
(
"
query_index
"
),
z
.
literal
(
"
query_engine
"
)]),
tool_kwargs
:
z
.
object
({
input
:
z
.
string
(),
}),
is_error
:
z
.
boolean
().
optional
(),
}).
optional
(),
return_direct
:
z
.
boolean
().
optional
(),
}).
transform
((
data
):
QueryIndex
=>
{
return
{
toolName
:
data
.
tool_name
,
toolKwargs
:
{
query
:
data
.
tool_kwargs
.
input
,
},
toolId
:
data
.
tool_id
,
toolOutput
:
data
.
tool_output
?
{
id
:
data
.
tool_id
,
result
:
data
.
tool_output
.
content
,
isError
:
data
.
tool_output
.
is_error
||
false
,
}
:
undefined
,
returnDirect
:
data
.
return_direct
||
false
,
};
});
tool_id
:
z
.
string
(),
tool_output
:
z
.
object
({
content
:
z
.
string
(),
tool_name
:
z
.
string
(),
raw_output
:
z
.
object
({
source_nodes
:
z
.
array
(
z
.
any
()),
}),
is_error
:
z
.
boolean
().
optional
(),
})
.
optional
(),
return_direct
:
z
.
boolean
().
optional
(),
})
.
transform
((
data
):
QueryIndex
=>
{
return
{
toolName
:
data
.
tool_name
,
toolKwargs
:
{
query
:
data
.
tool_kwargs
.
input
,
},
toolId
:
data
.
tool_id
,
toolOutput
:
data
.
tool_output
?
{
id
:
data
.
tool_id
,
result
:
data
.
tool_output
.
content
,
isError
:
data
.
tool_output
.
is_error
||
false
,
}
:
undefined
,
returnDirect
:
data
.
return_direct
||
false
,
};
});
type
GroupedIndexQuery
=
{
initial
:
QueryIndex
;
...
...
@@ -79,7 +87,7 @@ export function RetrieverComponent() {
const
queryIndexEvents
=
getCustomAnnotation
<
QueryIndex
>
(
message
.
annotations
,
(
annotation
)
=>
{
const
schema
=
'
toolName
'
in
annotation
?
TypeScriptSchema
:
PythonSchema
;
const
schema
=
"
toolName
"
in
annotation
?
TypeScriptSchema
:
PythonSchema
;
const
result
=
schema
.
safeParse
(
annotation
);
if
(
!
result
.
success
)
return
false
;
...
...
@@ -134,7 +142,7 @@ export function ChatSourcesComponent() {
message
.
annotations
,
(
annotation
)
=>
{
// If it looks like TypeScript format, validate it and check for toolOutput
if
(
'
toolName
'
in
annotation
)
{
if
(
"
toolName
"
in
annotation
)
{
const
result
=
TypeScriptSchema
.
safeParse
(
annotation
);
return
result
.
success
&&
!!
result
.
data
.
toolOutput
;
}
...
...
@@ -150,7 +158,7 @@ export function ChatSourcesComponent() {
);
const
sources
:
SourceNode
[]
=
useMemo
(()
=>
{
return
[];
// TypeScript format doesn't use source nodes
return
[];
// TypeScript format doesn't use source nodes
},
[
queryIndexEvents
]);
return
<
ChatSources
data
=
{
{
nodes
:
sources
}
}
/>;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment