-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
796 additions
and
177 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
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
examples/examples/pipeline/openai/create-chat-completion-async.py
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,38 @@ | ||
import asyncio | ||
import os | ||
|
||
import gentrace | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
|
||
async def main(): | ||
pipeline = gentrace.Pipeline( | ||
"test-gentrace-python-pipeline", | ||
os.getenv("GENTRACE_API_KEY"), | ||
host="http://localhost:3000/api/v1", | ||
openai_config={ | ||
"api_key": os.getenv("OPENAI_KEY"), | ||
}, | ||
) | ||
|
||
pipeline.setup() | ||
|
||
runner = pipeline.start() | ||
|
||
openai = runner.get_openai() | ||
|
||
result = await openai.ChatCompletion.acreate( | ||
messages=[{"role": "user", "content": "Hello!"}], | ||
model="gpt-3.5-turbo", | ||
) | ||
|
||
print("Result: ", result) | ||
|
||
info = runner.submit() | ||
|
||
print("Response: ", info["pipelineRunId"]) | ||
|
||
|
||
asyncio.run(main()) |
34 changes: 34 additions & 0 deletions
34
examples/examples/pipeline/openai/create-chat-completion-stream.py
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,34 @@ | ||
import os | ||
|
||
import gentrace | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
pipeline = gentrace.Pipeline( | ||
"test-gentrace-python-pipeline", | ||
os.getenv("GENTRACE_API_KEY"), | ||
host="http://localhost:3000/api/v1", | ||
openai_config={ | ||
"api_key": os.getenv("OPENAI_KEY"), | ||
}, | ||
) | ||
|
||
pipeline.setup() | ||
|
||
runner = pipeline.start() | ||
|
||
openai = runner.get_openai() | ||
|
||
result = openai.ChatCompletion.create( | ||
messages=[{"role": "user", "content": "Hello!"}], model="gpt-3.5-turbo", stream=True | ||
) | ||
|
||
for completion in result: | ||
pass | ||
|
||
print("Result: ", result) | ||
|
||
info = runner.submit() | ||
|
||
print("Response: ", info["pipelineRunId"]) |
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
File renamed without changes.
37 changes: 37 additions & 0 deletions
37
examples/examples/pipeline/openai/create-completion-async.py
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,37 @@ | ||
import asyncio | ||
import os | ||
|
||
import gentrace | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
|
||
async def main(): | ||
pipeline = gentrace.Pipeline( | ||
"test-gentrace-python-pipeline", | ||
os.getenv("GENTRACE_API_KEY"), | ||
host="http://localhost:3000/api/v1", | ||
openai_config={ | ||
"api_key": os.getenv("OPENAI_KEY"), | ||
}, | ||
) | ||
|
||
pipeline.setup() | ||
|
||
runner = pipeline.start() | ||
|
||
openai = runner.get_openai() | ||
|
||
await openai.Completion.acreate( | ||
model="text-davinci-003", | ||
prompt_template="Hello world {{ name }}", | ||
prompt_inputs={"name": "Vivek"}, | ||
) | ||
|
||
info = runner.submit() | ||
|
||
print("Response: ", info["pipelineRunId"]) | ||
|
||
|
||
asyncio.run(main()) |
37 changes: 37 additions & 0 deletions
37
examples/examples/pipeline/openai/create-completion-stream.py
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,37 @@ | ||
import os | ||
|
||
import gentrace | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
pipeline = gentrace.Pipeline( | ||
"test-gentrace-python-pipeline", | ||
os.getenv("GENTRACE_API_KEY"), | ||
host="http://localhost:3000/api/v1", | ||
openai_config={ | ||
"api_key": os.getenv("OPENAI_KEY"), | ||
}, | ||
) | ||
|
||
pipeline.setup() | ||
|
||
runner = pipeline.start() | ||
|
||
openai = runner.get_openai() | ||
|
||
result = openai.Completion.create( | ||
model="text-davinci-003", | ||
prompt_template="Hello world {{ name }}", | ||
prompt_inputs={"name": "test"}, | ||
stream=True, | ||
) | ||
|
||
for value in result: | ||
pass | ||
|
||
print("Result: ", result) | ||
|
||
info = runner.submit() | ||
|
||
print("Response: ", info["pipelineRunId"]) |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
examples/examples/self-contained/openai/create-embedding.py
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,23 @@ | ||
import os | ||
|
||
import gentrace | ||
from dotenv import load_dotenv | ||
from gentrace import providers | ||
|
||
load_dotenv() | ||
|
||
gentrace.api_key = os.getenv("GENTRACE_API_KEY") | ||
gentrace.host = "http://localhost:3000/api/v1" | ||
|
||
providers.openai_api_key = os.getenv("OPENAI_KEY") | ||
openai = providers.openai | ||
|
||
result = openai.Embedding.create( | ||
input="sample text", | ||
model="text-similarity-davinci-001", | ||
pipeline_id="testing-value", | ||
) | ||
|
||
gentrace.flush() | ||
|
||
print("Result: ", result.pipeline_run_id) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from gentrace.providers.getters import providers | ||
from gentrace.providers.pipeline import Pipeline | ||
from gentrace.providers.pipeline_run import PipelineRun | ||
from gentrace.providers.step_run import StepRun |
Oops, something went wrong.