mirror of
https://github.com/open-webui/pipelines
synced 2025-05-15 09:55:45 +00:00
refac
This commit is contained in:
parent
68cc31009e
commit
92890701f0
2
main.py
2
main.py
@ -14,7 +14,7 @@ from utils import get_last_user_message, stream_message_template
|
|||||||
from schemas import OpenAIChatCompletionForm
|
from schemas import OpenAIChatCompletionForm
|
||||||
from config import MODEL_ID, MODEL_NAME
|
from config import MODEL_ID, MODEL_NAME
|
||||||
|
|
||||||
from pipelines.examples.llamaindex_ollama_github_pipeline import (
|
from pipelines.pipeline import (
|
||||||
get_response,
|
get_response,
|
||||||
on_startup,
|
on_startup,
|
||||||
on_shutdown,
|
on_shutdown,
|
||||||
|
@ -3,7 +3,8 @@ from schemas import OpenAIChatMessage
|
|||||||
|
|
||||||
from llama_index.embeddings.ollama import OllamaEmbedding
|
from llama_index.embeddings.ollama import OllamaEmbedding
|
||||||
from llama_index.llms.ollama import Ollama
|
from llama_index.llms.ollama import Ollama
|
||||||
from llama_index.core import Settings
|
from llama_index.core import Settings, VectorStoreIndex, SimpleDirectoryReader
|
||||||
|
|
||||||
|
|
||||||
Settings.embed_model = OllamaEmbedding(
|
Settings.embed_model = OllamaEmbedding(
|
||||||
model_name="nomic-embed-text",
|
model_name="nomic-embed-text",
|
||||||
@ -11,10 +12,9 @@ Settings.embed_model = OllamaEmbedding(
|
|||||||
)
|
)
|
||||||
Settings.llm = Ollama(model="llama3")
|
Settings.llm = Ollama(model="llama3")
|
||||||
|
|
||||||
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
|
|
||||||
|
|
||||||
documents = SimpleDirectoryReader("./data").load_data()
|
documents = None
|
||||||
index = VectorStoreIndex.from_documents(documents)
|
index = None
|
||||||
|
|
||||||
|
|
||||||
def get_response(
|
def get_response(
|
||||||
@ -34,6 +34,11 @@ def get_response(
|
|||||||
|
|
||||||
async def on_startup():
|
async def on_startup():
|
||||||
# This function is called when the server is started.
|
# This function is called when the server is started.
|
||||||
|
global documents, index
|
||||||
|
|
||||||
|
documents = SimpleDirectoryReader("./data").load_data()
|
||||||
|
index = VectorStoreIndex.from_documents(documents)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user