Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Sec Insights
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
Sec Insights
Commits
e446ea9b
Unverified
Commit
e446ea9b
authored
1 year ago
by
Sourabh Desai
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
add scripts and other minor changes to make it easier to use custom documents with Chat REPL (#7)
parent
9b41590c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/app/chat/engine.py
+1
-0
1 addition, 0 deletions
backend/app/chat/engine.py
backend/scripts/chat_llama.py
+9
-8
9 additions, 8 deletions
backend/scripts/chat_llama.py
backend/scripts/upsert_document.py
+30
-0
30 additions, 0 deletions
backend/scripts/upsert_document.py
with
40 additions
and
8 deletions
backend/app/chat/engine.py
+
1
−
0
View file @
e446ea9b
...
...
@@ -275,6 +275,7 @@ async def get_chat_engine(
api_query_engine_tools
=
[
get_api_query_engine_tool
(
doc
,
service_context
)
for
doc
in
conversation
.
documents
if
DocumentMetadataKeysEnum
.
SEC_DOCUMENT
in
doc
.
metadata_map
]
quantitative_question_engine
=
SubQuestionQueryEngine
.
from_defaults
(
...
...
This diff is collapsed.
Click to expand it.
backend/scripts/chat_llama.py
+
9
−
8
View file @
e446ea9b
...
...
@@ -45,6 +45,14 @@ class DocumentPickerCmd(cmd.Cmd):
except
ValueError
:
print
(
"
Invalid index. Please enter a number.
"
)
def
do_select_id
(
self
,
document_id
):
"
Select a document by it
'
s ID
"
if
not
document_id
:
print
(
"
Please enter a valid document ID
"
)
else
:
self
.
selected_documents
.
append
({
"
id
"
:
document_id
})
print
(
f
"
Selected document ID
{
document_id
}
"
)
def
do_finish
(
self
,
args
):
"
Finish the document selection process: FINISH
"
if
len
(
self
.
selected_documents
)
>
0
:
...
...
@@ -141,14 +149,7 @@ class ConversationCmd(cmd.Cmd):
def
do_quit
(
self
,
args
):
"
Quits the program.
"
try
:
if
self
.
conversation_id
is
not
None
:
print
(
"
Quitting but first deleting convo.
"
)
self
.
do_delete
(
""
)
else
:
print
(
"
Quitting.
"
)
except
:
print
(
"
failed to delete
"
)
print
(
"
Quitting.
"
)
raise
SystemExit
...
...
This diff is collapsed.
Click to expand it.
backend/scripts/upsert_document.py
0 → 100644
+
30
−
0
View file @
e446ea9b
from
fire
import
Fire
from
app.schema
import
Document
from
app.db.session
import
SessionLocal
from
app.api
import
crud
import
asyncio
async
def
upsert_single_document
(
doc_url
:
str
):
"""
Upserts a single SEC document into the database using its URL.
"""
if
not
doc_url
or
not
doc_url
.
startswith
(
'
http
'
):
print
(
"
DOC_URL must be an http(s) based url value
"
)
return
metadata_map
=
{}
doc
=
Document
(
url
=
doc_url
,
metadata_map
=
metadata_map
)
async
with
SessionLocal
()
as
db
:
document
=
await
crud
.
upsert_document_by_url
(
db
,
doc
)
print
(
f
"
Upserted document. Database ID:
\n
{
document
.
id
}
"
)
def
main_upsert_single_document
(
doc_url
:
str
):
"""
Script to upsert a single document by URL. metada_map parameter will be empty dict ({})
This script is useful when trying to use your own PDF files.
"""
asyncio
.
run
(
upsert_single_document
(
doc_url
))
if
__name__
==
"
__main__
"
:
Fire
(
main_upsert_single_document
)
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