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
e2567ffc
Unverified
Commit
e2567ffc
authored
10 months ago
by
Marcus Schiesser
Committed by
GitHub
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
feat: use TOP_K env variable also for TS (#67)
parent
5d8d752b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
helpers/env-variables.ts
+22
-14
22 additions, 14 deletions
helpers/env-variables.ts
templates/components/engines/typescript/chat/chat.ts
+3
-1
3 additions, 1 deletion
templates/components/engines/typescript/chat/chat.ts
with
25 additions
and
15 deletions
helpers/env-variables.ts
+
22
−
14
View file @
e2567ffc
...
...
@@ -163,6 +163,14 @@ const getModelEnvs = (modelConfig: ModelConfig): EnvVar[] => {
description
:
"
The OpenAI API key to use.
"
,
value
:
modelConfig
.
apiKey
,
},
{
name
:
"
LLM_TEMPERATURE
"
,
description
:
"
Temperature for sampling from the model.
"
,
},
{
name
:
"
LLM_MAX_TOKENS
"
,
description
:
"
Maximum number of tokens to generate.
"
,
},
]
:
[]),
];
...
...
@@ -186,20 +194,7 @@ const getFrameworkEnvs = (
description
:
"
The port to start the backend app.
"
,
value
:
port
?.
toString
()
||
"
8000
"
,
},
{
name
:
"
LLM_TEMPERATURE
"
,
description
:
"
Temperature for sampling from the model.
"
,
},
{
name
:
"
LLM_MAX_TOKENS
"
,
description
:
"
Maximum number of tokens to generate.
"
,
},
{
name
:
"
TOP_K
"
,
description
:
"
The number of similar embeddings to return when retrieving documents.
"
,
value
:
"
3
"
,
},
// TODO: Once LlamaIndexTS supports string templates, move this to `getEngineEnvs`
{
name
:
"
SYSTEM_PROMPT
"
,
description
:
`Custom system prompt.
...
...
@@ -215,6 +210,17 @@ Given this information, please answer the question: {query_str}
];
};
const
getEngineEnvs
=
():
EnvVar
[]
=>
{
return
[
{
name
:
"
TOP_K
"
,
description
:
"
The number of similar embeddings to return when retrieving documents.
"
,
value
:
"
3
"
,
},
];
};
export
const
createBackendEnvFile
=
async
(
root
:
string
,
opts
:
{
...
...
@@ -236,6 +242,8 @@ export const createBackendEnvFile = async (
},
// Add model environment variables
...
getModelEnvs
(
opts
.
modelConfig
),
// Add engine environment variables
...
getEngineEnvs
(),
// Add vector database environment variables
...
getVectorDBEnvs
(
opts
.
vectorDb
),
...
getFrameworkEnvs
(
opts
.
framework
,
opts
.
port
),
...
...
This diff is collapsed.
Click to expand it.
templates/components/engines/typescript/chat/chat.ts
+
3
−
1
View file @
e2567ffc
...
...
@@ -9,7 +9,9 @@ export async function createChatEngine() {
);
}
const
retriever
=
index
.
asRetriever
();
retriever
.
similarityTopK
=
3
;
retriever
.
similarityTopK
=
process
.
env
.
TOP_K
?
parseInt
(
process
.
env
.
TOP_K
)
:
3
;
return
new
ContextChatEngine
({
chatModel
:
Settings
.
llm
,
...
...
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