Skip to content

Commit

Permalink
🐛 fix google palm bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sestinj committed Dec 6, 2023
1 parent 5a0d643 commit 8f8357b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
permissions:
contents: write
Expand Down
12 changes: 8 additions & 4 deletions server/continuedev/libs/llm/google_palm_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ async def _stream_complete(self, prompt, options):
api_url = f"https://generativelanguage.googleapis.com/v1beta2/models/{self.model}:generateMessage?key={self.api_key}"
body = {"prompt": {"messages": [{"content": prompt}]}}
response = requests.post(api_url, json=body)
yield response.json()["candidates"][0]["content"]
data = response.json()
if "candidates" in data:
yield data["candidates"][0]["content"]

async def _stream_chat(self, messages: List[ChatMessage], options):
msg_lst = []
Expand All @@ -41,6 +43,8 @@ async def _stream_chat(self, messages: List[ChatMessage], options):
api_url = f"https://generativelanguage.googleapis.com/v1beta2/models/{self.model}:generateMessage?key={self.api_key}"
body = {"prompt": {"messages": msg_lst}}
response = requests.post(api_url, json=body)
yield ChatMessage(
role="assistant", content=response.json()["candidates"][0]["content"]
)
data = response.json()
if "candidates" in data:
yield ChatMessage(
role="assistant", content=data["candidates"][0]["content"]
)

0 comments on commit 8f8357b

Please sign in to comment.