Skip to content

Commit

Permalink
feat: get_headers for complete and chat_complete
Browse files Browse the repository at this point in the history
  • Loading branch information
csgulati09 committed Mar 13, 2024
1 parent 354a10e commit ab20abb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions portkey_ai/api_resources/apis/chat_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ def normal_create(self, model, messages, **kwargs) -> ChatCompletions:
response = self.openai_client.with_raw_response.chat.completions.create(
model=model, messages=messages, **kwargs
)
json_response = json.loads(response.text)
return ChatCompletions(**json_response)
data = ChatCompletions(**json.loads(response.text))
data._headers = response.headers
return data

def create(
self,
Expand Down Expand Up @@ -114,8 +115,9 @@ async def normal_create(self, model, messages, **kwargs) -> ChatCompletions:
response = await self.openai_client.with_raw_response.chat.completions.create(
model=model, messages=messages, **kwargs
)
json_response = json.loads(response.text)
return ChatCompletions(**json_response)
data = ChatCompletions(**json.loads(response.text))
data._headers = response.headers
return data

async def create(
self,
Expand Down
10 changes: 6 additions & 4 deletions portkey_ai/api_resources/apis/complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ def normal_create(self, model, prompt, **kwargs) -> TextCompletion:
response = self.openai_client.with_raw_response.completions.create(
model=model, prompt=prompt, **kwargs
)
json_response = json.loads(response.text)
return TextCompletion(**json_response)
data = TextCompletion(**json.loads(response.text))
data._headers = response.headers
return data

def create(
self,
Expand Down Expand Up @@ -86,8 +87,9 @@ async def normal_create(self, model, prompt, **kwargs) -> TextCompletion:
response = await self.openai_client.with_raw_response.completions.create(
model=model, prompt=prompt, **kwargs
)
json_response = json.loads(response.text)
return TextCompletion(**json_response)
data = TextCompletion(**json.loads(response.text))
data._headers = response.headers
return data

async def create(
self,
Expand Down

0 comments on commit ab20abb

Please sign in to comment.