Skip to content

Commit

Permalink
Release (#67)
Browse files Browse the repository at this point in the history
* 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

---------

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]>
  • Loading branch information
5 people authored Apr 5, 2024
1 parent 0f5ec89 commit d807ae3
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/langtrace_python_sdk/instrumentation/openai/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,20 @@ def traced_method(wrapped, instance, args, kwargs):
span.end()
return result
else:
prompt_tokens = calculate_prompt_tokens(
json.dumps(kwargs.get("messages", {})[0]), kwargs.get("model")
)
# iterate over kwargs.get("messages", {}) and calculate the prompt tokens
prompt_tokens = 0
for message in kwargs.get("messages", {}):
prompt_tokens += calculate_prompt_tokens(
json.dumps(message), kwargs.get("model")
)

# iterate over kwargs.get("functions") and calculate the prompt tokens
if kwargs.get("functions") is not None:
for function in kwargs.get("functions"):
prompt_tokens += calculate_prompt_tokens(
json.dumps(function), kwargs.get("model")
)

return handle_streaming_response(
result,
span,
Expand Down Expand Up @@ -289,7 +300,7 @@ def handle_streaming_response(result, span, prompt_tokens, function_call=False):
{
"message": {
"role": "assistant",
"function_call": "".join(result_content),
"content": "".join(result_content),
}
}
),
Expand Down

0 comments on commit d807ae3

Please sign in to comment.