-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from Scale3-Labs/development
Release Ollama + disable vendor specific functions
- Loading branch information
Showing
36 changed files
with
688 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ dev = [ | |
"cohere", | ||
"qdrant_client", | ||
"weaviate-client", | ||
"ollama" | ||
] | ||
|
||
test = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from .basic import chat, async_chat, async_generate, generate, embed, async_embed | ||
from langtrace_python_sdk import with_langtrace_root_span | ||
import asyncio | ||
|
||
|
||
class OllamaRunner: | ||
@with_langtrace_root_span("OllamaRunner") | ||
def run(self): | ||
chat() | ||
generate() | ||
embed() | ||
asyncio.run(async_chat()) | ||
asyncio.run(async_generate()) | ||
asyncio.run(async_embed()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from langtrace_python_sdk import langtrace, with_langtrace_root_span | ||
import ollama | ||
from ollama import AsyncClient | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
langtrace.init(write_spans_to_console=False) | ||
|
||
|
||
def chat(): | ||
response = ollama.chat( | ||
model="llama3", | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": "hi", | ||
}, | ||
], | ||
stream=True, | ||
) | ||
|
||
return response | ||
|
||
|
||
async def async_chat(): | ||
message = {"role": "user", "content": "Why is the sky blue?"} | ||
return await AsyncClient().chat(model="llama3", messages=[message]) | ||
|
||
|
||
def generate(): | ||
return ollama.generate(model="llama3", prompt="Why is the sky blue?") | ||
|
||
|
||
def async_generate(): | ||
return AsyncClient().generate(model="llama3", prompt="Why is the sky blue?") | ||
|
||
|
||
def embed(): | ||
return ollama.embeddings( | ||
model="llama3", | ||
prompt="cat", | ||
) | ||
|
||
|
||
async def async_embed(): | ||
return await AsyncClient().embeddings( | ||
model="llama3", | ||
prompt="cat", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
APIS = { | ||
"GENERATE": { | ||
"METHOD": "generate", | ||
}, | ||
"CHAT": {"METHOD": "chat"}, | ||
"EMBEDDINGS": {"METHOD": "embeddings"}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.