-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated test_chat_completion and added test_anthropic. Updated tests/utils * Updated tests/utils * updated langchain test cases * updated test_langchain * updated test_image_generation * Bugfix * Bump version * Cleanup logging (#56) * Fix streaming bug (#57) * Cleanup logging * Fix streaming bug * bump version * add sdk name (#60) * Bump trace-attributes (#62) * add model for streaming * Add model for streaming (#65) * Release 1.2.13 (#55) * Updated test_chat_completion and added test_anthropic. Updated tests/utils * Updated tests/utils * updated langchain test cases * updated test_langchain * updated test_image_generation * Bugfix * Bump version --------- Co-authored-by: Ali Waleed <[email protected]> Co-authored-by: MayuriS24 <[email protected]> Co-authored-by: Rohit Kadhe <[email protected]> * Bump version * Release (#58) * Updated test_chat_completion and added test_anthropic. Updated tests/utils * Updated tests/utils * updated langchain test cases * updated test_langchain * updated test_image_generation * Bugfix * Bump version * Cleanup logging (#56) * Fix streaming bug (#57) * Cleanup logging * Fix streaming bug --------- Co-authored-by: Ali Waleed <[email protected]> Co-authored-by: MayuriS24 <[email protected]> Co-authored-by: Rohit Kadhe <[email protected]> * Release (#59) * Updated test_chat_completion and added test_anthropic. Updated tests/utils * Updated tests/utils * updated langchain test cases * updated test_langchain * updated test_image_generation * Bugfix * Bump version * Cleanup logging (#56) * Fix streaming bug (#57) * Cleanup logging * Fix streaming bug * bump version --------- Co-authored-by: Ali Waleed <[email protected]> Co-authored-by: MayuriS24 <[email protected]> Co-authored-by: Rohit Kadhe <[email protected]> * Bump version * Release (#61) * Updated test_chat_completion and added test_anthropic. Updated tests/utils * Updated tests/utils * updated langchain test cases * updated test_langchain * updated test_image_generation * Bugfix * Bump version * Cleanup logging (#56) * Fix streaming bug (#57) * Cleanup logging * Fix streaming bug * bump version * add sdk name (#60) --------- Co-authored-by: Ali Waleed <[email protected]> Co-authored-by: MayuriS24 <[email protected]> Co-authored-by: Rohit Kadhe <[email protected]> * Bump version * Release (#63) * Updated test_chat_completion and added test_anthropic. Updated tests/utils * Updated tests/utils * updated langchain test cases * updated test_langchain * updated test_image_generation * Bugfix * Bump version * Cleanup logging (#56) * Fix streaming bug (#57) * Cleanup logging * Fix streaming bug * bump version * add sdk name (#60) * Bump trace-attributes (#62) --------- Co-authored-by: Ali Waleed <[email protected]> Co-authored-by: MayuriS24 <[email protected]> Co-authored-by: Rohit Kadhe <[email protected]> * Bump version * Release (#64) * Updated test_chat_completion and added test_anthropic. Updated tests/utils * Updated tests/utils * updated langchain test cases * updated test_langchain * updated test_image_generation * Bugfix * Bump version * Cleanup logging (#56) * Fix streaming bug (#57) * Cleanup logging * Fix streaming bug * bump version * add sdk name (#60) * Bump trace-attributes (#62) * add model for streaming --------- Co-authored-by: Ali Waleed <[email protected]> Co-authored-by: MayuriS24 <[email protected]> Co-authored-by: Rohit Kadhe <[email protected]> --------- Co-authored-by: Ali Waleed <[email protected]> Co-authored-by: MayuriS24 <[email protected]> Co-authored-by: Rohit Kadhe <[email protected]> Co-authored-by: karthikscale3 <[email protected]> * Bugfix function calling (#66) * fix function calling * prompt token calculation fix * Minor bugfix (#68) * fix * Fix * add flask django and fastapi examples (#75) * Add perplexity support (#76) * Add perplexity support * fix * version bump * bump version * Add FastAPI example (#79) * Cohere instrumentation (#80) * added cohere instrtumentation * Cohere chat * Fix streaming * cohere support --------- Co-authored-by: chandrasekharscale3 <[email protected]> * Update readme --------- Co-authored-by: Ali Waleed <[email protected]> Co-authored-by: MayuriS24 <[email protected]> Co-authored-by: Rohit Kadhe <[email protected]> Co-authored-by: karthikscale3 <[email protected]> Co-authored-by: chandrasekharscale3 <[email protected]>
- Loading branch information
1 parent
32b3dd9
commit c22d3b2
Showing
15 changed files
with
700 additions
and
24 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
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,33 +1,58 @@ | ||
bcrypt==4.1.2 | ||
aiohttp==3.9.3 | ||
aiosignal==1.3.1 | ||
annotated-types==0.6.0 | ||
anthropic==0.19.1 | ||
anyio==4.3.0 | ||
appnope==0.1.4 | ||
argon2-cffi==23.1.0 | ||
argon2-cffi-bindings==21.2.0 | ||
arrow==1.3.0 | ||
asgiref==3.7.2 | ||
asttokens==2.4.1 | ||
async-lru==2.0.4 | ||
async-timeout==4.0.3 | ||
attrs==23.2.0 | ||
Babel==2.14.0 | ||
backoff==2.2.1 | ||
bcrypt==4.1.2 | ||
beautifulsoup4==4.12.3 | ||
bleach==6.1.0 | ||
bs4==0.0.2 | ||
build==1.0.3 | ||
CacheControl==0.14.0 | ||
cachetools==5.3.3 | ||
cattrs==23.2.3 | ||
certifi==2024.2.2 | ||
cffi==1.16.0 | ||
charset-normalizer==3.3.2 | ||
chroma-hnswlib==0.7.3 | ||
chromadb==0.4.23 | ||
chromadb==0.4.24 | ||
cleo==2.1.0 | ||
click==8.1.7 | ||
cohere==5.2.5 | ||
coloredlogs==15.0.1 | ||
comm==0.2.2 | ||
contextvars==2.4 | ||
crashtest==0.4.1 | ||
dataclasses-json==0.6.4 | ||
debugpy==1.8.1 | ||
decorator==5.1.1 | ||
defusedxml==0.7.1 | ||
Deprecated==1.2.14 | ||
dirtyjson==1.0.8 | ||
distlib==0.3.8 | ||
distro==1.9.0 | ||
docarray==0.40.0 | ||
dulwich==0.21.7 | ||
exceptiongroup==1.2.0 | ||
executing==2.0.1 | ||
faiss-cpu==1.7.4 | ||
fastapi==0.110.0 | ||
fastavro==1.9.4 | ||
fastjsonschema==2.19.1 | ||
filelock==3.13.1 | ||
flatbuffers==23.5.26 | ||
fqdn==1.5.1 | ||
frozenlist==1.4.1 | ||
fsspec==2024.2.0 | ||
google-auth==2.28.1 | ||
|
@@ -41,18 +66,46 @@ httpx==0.27.0 | |
huggingface-hub==0.20.3 | ||
humanfriendly==10.0 | ||
idna==3.6 | ||
immutables==0.20 | ||
importlib-metadata==6.11.0 | ||
importlib_resources==6.1.2 | ||
iniconfig==2.0.0 | ||
installer==0.7.0 | ||
ipykernel==6.29.3 | ||
ipython==8.22.2 | ||
ipywidgets==8.1.2 | ||
isoduration==20.11.0 | ||
jaraco.classes==3.3.1 | ||
jedi==0.19.1 | ||
Jinja2==3.1.3 | ||
joblib==1.3.2 | ||
json5==0.9.24 | ||
jsonpatch==1.33 | ||
jsonpointer==2.4 | ||
jsonschema==4.21.1 | ||
jsonschema-specifications==2023.12.1 | ||
jupyter==1.0.0 | ||
jupyter-console==6.6.3 | ||
jupyter-events==0.10.0 | ||
jupyter-lsp==2.2.4 | ||
jupyter_client==8.6.1 | ||
jupyter_core==5.7.2 | ||
jupyter_server==2.13.0 | ||
jupyter_server_terminals==0.5.3 | ||
jupyterlab==4.1.5 | ||
jupyterlab_pygments==0.3.0 | ||
jupyterlab_server==2.25.4 | ||
jupyterlab_widgets==3.0.10 | ||
keyring==24.3.1 | ||
kubernetes==29.0.0 | ||
langchain==0.1.9 | ||
langchain-community==0.0.24 | ||
langchain-core==0.1.35 | ||
langchain-openai==0.0.7 | ||
langchainhub==0.1.14 | ||
langsmith==0.1.9 | ||
-e git+ssh://[email protected]/Scale3-Labs/langtrace-python-sdk.git@a6583c0595c5f1b9e8e68c12c500d16a5c37425d#egg=langtrace_python_sdk | ||
Levenshtein==0.25.0 | ||
llama-index==0.10.13.post1 | ||
llama-index-agent-openai==0.1.5 | ||
llama-index-cli==0.1.5 | ||
|
@@ -70,45 +123,76 @@ llama-index-vector-stores-chroma==0.1.4 | |
llama-parse==0.3.4 | ||
llamaindex-py-client==0.1.13 | ||
markdown-it-py==3.0.0 | ||
MarkupSafe==2.1.5 | ||
marshmallow==3.21.0 | ||
matplotlib-inline==0.1.6 | ||
mdurl==0.1.2 | ||
mistune==3.0.2 | ||
mmh3==4.1.0 | ||
monotonic==1.6 | ||
more-itertools==10.2.0 | ||
mpmath==1.3.0 | ||
msgpack==1.0.8 | ||
multidict==6.0.5 | ||
mypy-extensions==1.0.0 | ||
nbclient==0.10.0 | ||
nbconvert==7.16.3 | ||
nbformat==5.10.3 | ||
nest-asyncio==1.6.0 | ||
networkx==3.2.1 | ||
nltk==3.8.1 | ||
notebook==7.1.2 | ||
notebook_shim==0.2.4 | ||
numexpr==2.9.0 | ||
numpy==1.26.4 | ||
oauthlib==3.2.2 | ||
onnxruntime==1.17.1 | ||
openai==1.12.0 | ||
opentelemetry-api==1.23.0 | ||
opentelemetry-distro==0.44b0 | ||
opentelemetry-exporter-otlp==1.23.0 | ||
opentelemetry-exporter-otlp-proto-common==1.23.0 | ||
opentelemetry-exporter-otlp-proto-grpc==1.23.0 | ||
opentelemetry-exporter-otlp-proto-http==1.23.0 | ||
opentelemetry-instrumentation==0.44b0 | ||
opentelemetry-instrumentation-asgi==0.44b0 | ||
opentelemetry-instrumentation-fastapi==0.44b0 | ||
opentelemetry-proto==1.23.0 | ||
opentelemetry-sdk==1.23.0 | ||
opentelemetry-semantic-conventions==0.44b0 | ||
opentelemetry-util-http==0.44b0 | ||
opentelemetry-api==1.22.0 | ||
opentelemetry-distro==0.43b0 | ||
opentelemetry-exporter-otlp==1.22.0 | ||
opentelemetry-exporter-otlp-proto-common==1.22.0 | ||
opentelemetry-exporter-otlp-proto-grpc==1.22.0 | ||
opentelemetry-exporter-otlp-proto-http==1.22.0 | ||
opentelemetry-instrumentation==0.43b0 | ||
opentelemetry-instrumentation-aiohttp-client==0.43b0 | ||
opentelemetry-instrumentation-asgi==0.43b0 | ||
opentelemetry-instrumentation-aws-lambda==0.43b0 | ||
opentelemetry-instrumentation-dbapi==0.43b0 | ||
opentelemetry-instrumentation-fastapi==0.43b0 | ||
opentelemetry-instrumentation-logging==0.43b0 | ||
opentelemetry-instrumentation-sqlite3==0.43b0 | ||
opentelemetry-instrumentation-urllib==0.43b0 | ||
opentelemetry-instrumentation-wsgi==0.43b0 | ||
opentelemetry-propagator-aws-xray==1.0.1 | ||
opentelemetry-proto==1.22.0 | ||
opentelemetry-sdk==1.22.0 | ||
opentelemetry-semantic-conventions==0.43b0 | ||
opentelemetry-util-http==0.43b0 | ||
orjson==3.9.15 | ||
overrides==7.7.0 | ||
packaging==23.2 | ||
pandas==2.2.1 | ||
pillow==10.3.0 | ||
pinecone-client==3.1.0 | ||
pkginfo==1.10.0 | ||
platformdirs==4.2.0 | ||
pluggy==1.4.0 | ||
poetry==1.8.2 | ||
poetry-core==1.9.0 | ||
poetry-plugin-dotenv==0.6.28 | ||
poetry-plugin-export==1.7.1 | ||
posthog==3.4.2 | ||
prometheus_client==0.20.0 | ||
prompt-toolkit==3.0.43 | ||
protobuf==4.25.3 | ||
psutil==5.9.8 | ||
ptyprocess==0.7.0 | ||
pulsar-client==3.4.0 | ||
pure-eval==0.2.2 | ||
pyasn1==0.5.1 | ||
pyasn1-modules==0.3.0 | ||
pycparser==2.21 | ||
pydantic==2.6.2 | ||
pydantic_core==2.16.3 | ||
Pygments==2.17.2 | ||
|
@@ -117,39 +201,71 @@ PyMuPDFb==1.23.22 | |
pypdf==4.0.2 | ||
PyPika==0.48.9 | ||
pyproject_hooks==1.0.0 | ||
pysbd==0.3.4 | ||
pytest==8.1.1 | ||
python-dateutil==2.8.2 | ||
python-dotenv==1.0.1 | ||
python-json-logger==2.0.7 | ||
pytz==2024.1 | ||
pyupgrade==3.15.1 | ||
PyYAML==6.0.1 | ||
pyzmq==25.1.2 | ||
qtconsole==5.5.1 | ||
QtPy==2.4.1 | ||
rapidfuzz==3.6.2 | ||
redis==5.0.3 | ||
referencing==0.34.0 | ||
regex==2023.12.25 | ||
requests==2.31.0 | ||
requests-oauthlib==1.3.1 | ||
requests-toolbelt==1.0.0 | ||
rfc3339-validator==0.1.4 | ||
rfc3986-validator==0.1.1 | ||
rich==13.7.0 | ||
rpds-py==0.18.0 | ||
rsa==4.9 | ||
Send2Trash==1.8.2 | ||
shellingham==1.5.4 | ||
six==1.16.0 | ||
sniffio==1.3.0 | ||
soupsieve==2.5 | ||
SQLAlchemy==2.0.27 | ||
stack-data==0.6.3 | ||
starlette==0.36.3 | ||
sympy==1.12 | ||
tenacity==8.2.3 | ||
terminado==0.18.1 | ||
tiktoken==0.6.0 | ||
tinycss2==1.2.1 | ||
tokenize-rt==5.2.0 | ||
tokenizers==0.15.2 | ||
tomli==2.0.1 | ||
tomlkit==0.12.4 | ||
tornado==6.4 | ||
tqdm==4.66.2 | ||
trace-attributes==1.0.28 | ||
trace-attributes==1.0.32 | ||
traitlets==5.14.2 | ||
trove-classifiers==2024.3.3 | ||
typer==0.9.0 | ||
types-python-dateutil==2.9.0.20240316 | ||
types-requests==2.31.0.20240218 | ||
typing==3.7.4.3 | ||
typing-inspect==0.9.0 | ||
typing_extensions==4.9.0 | ||
tzdata==2024.1 | ||
uri-template==1.3.0 | ||
urllib3==2.2.1 | ||
uvicorn==0.27.1 | ||
uvloop==0.19.0 | ||
virtualenv==20.25.1 | ||
watchfiles==0.21.0 | ||
wcwidth==0.2.13 | ||
webcolors==1.13 | ||
webencodings==0.5.1 | ||
websocket-client==1.7.0 | ||
websockets==12.0 | ||
widgetsnbextension==4.0.10 | ||
wrapt==1.16.0 | ||
xattr==1.1.0 | ||
yarl==1.9.4 | ||
zipp==3.17.0 |
Empty file.
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,26 @@ | ||
from dotenv import find_dotenv, load_dotenv | ||
import cohere | ||
|
||
from langtrace_python_sdk import langtrace | ||
# from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span | ||
|
||
_ = load_dotenv(find_dotenv()) | ||
|
||
langtrace.init(batch=False, debug_log_to_console=True, write_to_langtrace_cloud=False) | ||
|
||
co = cohere.Client() | ||
|
||
|
||
# @with_langtrace_root_span("chat_create") | ||
def chat_comp(): | ||
response = co.chat( | ||
chat_history=[ | ||
{"role": "USER", "message": "Who discovered gravity?"}, | ||
{"role": "CHATBOT", "message": "The man who is widely credited with discovering gravity is Sir Isaac Newton"} | ||
], | ||
message="What is today's news?", | ||
# preamble="answer like yoda", | ||
# perform web search before answering the question. You can also use your own custom connector. | ||
# connectors=[{"id": "web-search"}] | ||
) | ||
print(response) |
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 @@ | ||
from dotenv import find_dotenv, load_dotenv | ||
import cohere | ||
|
||
from langtrace_python_sdk import langtrace | ||
# from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span | ||
|
||
_ = load_dotenv(find_dotenv()) | ||
|
||
langtrace.init(batch=False, debug_log_to_console=True, write_to_langtrace_cloud=False) | ||
|
||
co = cohere.Client() | ||
|
||
|
||
# @with_langtrace_root_span("chat_stream") | ||
def chat_stream(): | ||
result = [] | ||
for event in co.chat_stream(message="Tell me a short story in 2 lines"): | ||
if event.event_type == "text-generation": | ||
result.append(event.text) | ||
elif event.event_type == "stream-end": | ||
break | ||
print("".join(result)) | ||
return result |
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,21 @@ | ||
from dotenv import find_dotenv, load_dotenv | ||
import cohere | ||
|
||
from langtrace_python_sdk import langtrace | ||
# from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span | ||
|
||
_ = load_dotenv(find_dotenv()) | ||
|
||
langtrace.init(batch=False, debug_log_to_console=True, write_to_langtrace_cloud=False) | ||
|
||
co = cohere.Client() | ||
|
||
|
||
# @with_langtrace_root_span("embed_create") | ||
def embed_create(): | ||
response = co.embed( | ||
texts=['hello', 'goodbye'], | ||
model='embed-english-v3.0', | ||
input_type='classification' | ||
) | ||
# print(response) |
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 @@ | ||
from fastapi import FastAPI | ||
from langchain_community.vectorstores.faiss import FAISS | ||
from langchain_core.output_parsers import StrOutputParser | ||
from langchain_core.prompts.chat import ChatPromptTemplate | ||
from langchain_core.runnables import RunnablePassthrough | ||
from langchain_openai import ChatOpenAI, OpenAIEmbeddings | ||
from openai import OpenAI | ||
|
||
from langtrace_python_sdk import langtrace | ||
|
||
langtrace.init(write_to_langtrace_cloud=False, debug_log_to_console=True) | ||
app = FastAPI() | ||
client = OpenAI() | ||
|
||
@app.get("/") | ||
def root(): | ||
vectorstore = FAISS.from_texts( | ||
["Langtrace helps you ship high quality AI Apps to production."], embedding=OpenAIEmbeddings() | ||
) | ||
retriever = vectorstore.as_retriever() | ||
|
||
template = """Answer the question based only on the following context:{context} | ||
Question: {question} | ||
""" | ||
prompt = ChatPromptTemplate.from_template(template) | ||
|
||
model = ChatOpenAI() | ||
|
||
chain = ( | ||
{"context": retriever, "question": RunnablePassthrough()} | ||
| prompt | ||
| model | ||
| StrOutputParser() | ||
) | ||
|
||
res = chain.invoke("How is Langtrace useful?") | ||
return {"response": res} |
Oops, something went wrong.