Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 25d6d4a3c0 |
@@ -41,8 +41,6 @@ try:
|
|||||||
except ImportError: # pragma: no cover - optional at runtime
|
except ImportError: # pragma: no cover - optional at runtime
|
||||||
anthropic = None
|
anthropic = None
|
||||||
|
|
||||||
# this do per user
|
|
||||||
VECTOR_STORE_ID = -1
|
|
||||||
|
|
||||||
|
|
||||||
# *=========================================== AI provider abstraction
|
# *=========================================== AI provider abstraction
|
||||||
@@ -410,58 +408,6 @@ async def openai_call(messages, model, temperature=0.2):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_vector_store():
|
|
||||||
# Create a vector store caled "Financial Statements"
|
|
||||||
return OPENAICLIENT.beta.vector_stores.create_and_poll(name="Hammer Stash")
|
|
||||||
# expires_after={
|
|
||||||
# "anchor": "last_active_at",
|
|
||||||
# "days": 7}
|
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
def upload_files_to_vector_store(assistant):
|
|
||||||
|
|
||||||
# Ready the files for upload to OpenAI
|
|
||||||
file_paths = ["edgar/goog-10k.pdf", "edgar/brka-10k.txt"]
|
|
||||||
file_streams = [open(path, "rb") for path in file_paths]
|
|
||||||
|
|
||||||
# file = client.beta.vector_stores.files.create_and_poll(
|
|
||||||
# vector_store_id="vs_abc123",
|
|
||||||
# file_id="file-abc123"
|
|
||||||
# )
|
|
||||||
# batch = client.beta.vector_stores.file_batches.create_and_poll(
|
|
||||||
# vector_store_id="vs_abc123",
|
|
||||||
# file_ids=['file_1', 'file_2', 'file_3', 'file_4', 'file_5']
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Use the upload and poll SDK helper to upload the files, add them to the vector store,
|
|
||||||
# and poll the status of the file batch for completion.
|
|
||||||
file_batch = OPENAICLIENT.beta.vector_stores.file_batches.upload_and_poll(
|
|
||||||
vector_store_id=VECTOR_STORE_ID, files=file_streams
|
|
||||||
)
|
|
||||||
|
|
||||||
# You can print the status and the file counts of the batch to see the result of this operation.
|
|
||||||
print(file_batch.status)
|
|
||||||
print(file_batch.file_counts)
|
|
||||||
assistant = OPENAICLIENT.beta.assistants.update(
|
|
||||||
assistant_id=assistant.id,
|
|
||||||
tool_resources={"file_search": {"vector_store_ids": [VECTOR_STORE_ID]}},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def delete_files_from_vector_store(assistant, file_id):
|
|
||||||
result = OPENAICLIENT.beta.vector_stores.file_batches.delete(
|
|
||||||
vector_store_id=VECTOR_STORE_ID, files=file_id
|
|
||||||
)
|
|
||||||
|
|
||||||
# You can print the status and the file counts of the batch to see the result of this operation.
|
|
||||||
print(result)
|
|
||||||
assistant = OPENAICLIENT.beta.assistants.update(
|
|
||||||
assistant_id=assistant.id,
|
|
||||||
tool_resources={"file_search": {"vector_store_ids": [VECTOR_STORE_ID]}},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def num_tokens_from_string(message, model):
|
def num_tokens_from_string(message, model):
|
||||||
"""
|
"""
|
||||||
The function takes a string message and a model as input and returns the number of tokens in the
|
The function takes a string message and a model as input and returns the number of tokens in the
|
||||||
|
|||||||
Reference in New Issue
Block a user