Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LlamaIndexTS
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
LlamaIndexTS
Commits
29d04217
Commit
29d04217
authored
1 year ago
by
Yi Ding
Browse files
Options
Downloads
Patches
Plain Diff
initial work
parent
bbf936e9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
packages/core/src/QueryEngine.ts
+21
-1
21 additions, 1 deletion
packages/core/src/QueryEngine.ts
packages/core/src/QuestionGenerator.ts
+29
-0
29 additions, 0 deletions
packages/core/src/QuestionGenerator.ts
packages/core/src/Tool.ts
+1
-0
1 addition, 0 deletions
packages/core/src/Tool.ts
with
51 additions
and
1 deletion
packages/core/src/QueryEngine.ts
+
21
−
1
View file @
29d04217
import
{
BaseQuestionGenerator
,
LLMQuestionGenerator
,
}
from
"
./QuestionGenerator
"
;
import
{
Response
}
from
"
./Response
"
;
import
{
ResponseSynthesizer
}
from
"
./ResponseSynthesizer
"
;
import
{
BaseRetriever
}
from
"
./Retriever
"
;
...
...
@@ -6,7 +10,7 @@ export interface BaseQueryEngine {
aquery
(
query
:
string
):
Promise
<
Response
>
;
}
export
class
RetrieverQueryEngine
{
export
class
RetrieverQueryEngine
implements
BaseQueryEngine
{
retriever
:
BaseRetriever
;
responseSynthesizer
:
ResponseSynthesizer
;
...
...
@@ -20,3 +24,19 @@ export class RetrieverQueryEngine {
return
this
.
responseSynthesizer
.
asynthesize
(
query
,
nodes
);
}
}
export
class
SubQuestionQueryEngine
implements
BaseQueryEngine
{
responseSynthesizer
:
ResponseSynthesizer
;
questionGenerator
:
BaseQuestionGenerator
;
constructor
(
init
?:
Partial
<
SubQuestionQueryEngine
>
)
{
this
.
responseSynthesizer
=
init
?.
responseSynthesizer
??
new
ResponseSynthesizer
();
this
.
questionGenerator
=
init
?.
questionGenerator
??
new
LLMQuestionGenerator
();
}
aquery
(
query
:
string
):
Promise
<
Response
>
{
throw
new
Error
(
"
Method not implemented.
"
);
}
}
This diff is collapsed.
Click to expand it.
packages/core/src/QuestionGenerator.ts
0 → 100644
+
29
−
0
View file @
29d04217
import
{
BaseLLMPredictor
}
from
"
./LLMPredictor
"
;
import
{
SimplePrompt
}
from
"
./Prompt
"
;
import
{
ToolMetadata
}
from
"
./Tool
"
;
export
interface
BaseQuestionGenerator
{
agenerate
(
tools
:
ToolMetadata
[],
query
:
string
):
Promise
<
SubQuestion
[]
>
;
}
export
class
LLMQuestionGenerator
implements
BaseQuestionGenerator
{
llmPredictor
:
BaseLLMPredictor
;
prompt
:
SimplePrompt
;
constructor
(
init
?:
Partial
<
LLMQuestionGenerator
>
)
{
this
.
llmPredictor
=
init
?.
llmPredictor
??
new
BaseLLMPredictor
();
this
.
prompt
=
init
?.
prompt
??
new
SimplePrompt
();
}
async
agenerate
(
tools
:
ToolMetadata
[],
query
:
string
):
Promise
<
SubQuestion
[]
>
{
throw
new
Error
(
"
Method not implemented.
"
);
}
}
interface
SubQuestion
{
subQuestion
:
string
;
toolName
:
string
;
}
This diff is collapsed.
Click to expand it.
packages/core/src/Tool.ts
0 → 100644
+
1
−
0
View file @
29d04217
export
interface
ToolMetadata
{}
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