Skip to content

Commit

Permalink
Merge branch 'main' into nqn/download-large-image
Browse files Browse the repository at this point in the history
  • Loading branch information
kxtran committed Jun 17, 2024
2 parents 849fcf9 + 2e30886 commit 3eac86d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
11 changes: 7 additions & 4 deletions examples/logging/google_genai_gemini_chat_w_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
log10(genai)


model = genai.GenerativeModel("gemini-1.5-pro-latest", system_instruction="You are a cat. Your name is Neko.")
model = genai.GenerativeModel(
"gemini-1.5-pro-latest",
system_instruction="You will be provided with statements, and your task is to convert them to standard English.",
)
chat = model.start_chat(
history=[
{"role": "user", "parts": [{"text": "please say yes."}]},
{"role": "model", "parts": [{"text": "Yes yes yes?"}]},
{"role": "user", "parts": [{"text": "He no went to the market."}]},
{"role": "model", "parts": [{"text": "He did not go to the market."}]},
]
)

prompt = "please say no."
prompt = "She no went to the market."
response = chat.send_message(prompt)

print(response.text)
10 changes: 5 additions & 5 deletions log10/_httpx_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ def format_anthropic_tools_request(request_content) -> str:
async def get_completion_id(request: Request):
host = request.headers.get("host")
if "anthropic" in host and "/v1/messages" not in str(request.url):
logger.warning("Currently logging is only available for anthropic v1/messages.")
logger.debug("Currently logging is only available for anthropic v1/messages.")
return

if "openai" in host and "v1/chat/completions" not in str(request.url):
logger.warning("Currently logging is only available for openai v1/chat/completions.")
logger.debug("Currently logging is only available for openai v1/chat/completions.")
return

request.headers["x-log10-completion-id"] = str(uuid.uuid4())
Expand Down Expand Up @@ -209,7 +209,7 @@ async def log_request(request: Request):
orig_module = "anthropic.resources.messages"
orig_qualname = "Messages.stream"
else:
logger.warning("Currently logging is only available for async openai and anthropic.")
logger.debug("Currently logging is only available for async openai and anthropic.")
return
log_row = {
"status": "started",
Expand Down Expand Up @@ -318,7 +318,7 @@ def is_response_end_reached(self, text: str):
elif "openai" in host:
return self.is_openai_response_end_reached(text)
else:
logger.warning("Currently logging is only available for async openai and anthropic.")
logger.debug("Currently logging is only available for async openai and anthropic.")
return False

def is_anthropic_response_end_reached(self, text: str):
Expand Down Expand Up @@ -447,7 +447,7 @@ def parse_response_data(self, responses: list[str]):
elif "anthropic" in host:
return self.parse_anthropic_responses(responses)
else:
logger.warning("Currently logging is only available for async openai and anthropic.")
logger.debug("Currently logging is only available for async openai and anthropic.")
return None


Expand Down
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mistralai = {version = "^0.1.5", optional = true}
together = {version = "^0.2.7", optional = true}
mosaicml-cli = {version = "^0.5.30", optional = true}
google-cloud-bigquery = {version = "^3.11.4", optional = true}
google-generativeai = {version = "^0.5.2", optional = true}
google-generativeai = {version = "^0.6.0", optional = true}

[tool.poetry.extras]
autofeedback_icl = ["magentic"]
Expand Down
11 changes: 7 additions & 4 deletions tests/test_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ def test_genai_chat(session, google_model):

@pytest.mark.chat
def test_genai_chat_w_history(session, google_model):
model = genai.GenerativeModel(google_model, system_instruction="You are a cat. Your name is Neko.")
model = genai.GenerativeModel(
google_model,
system_instruction="You will be provided with statements, and your task is to convert them to standard English.",
)
chat = model.start_chat(
history=[
{"role": "user", "parts": [{"text": "please say yes."}]},
{"role": "model", "parts": [{"text": "Yes yes yes?"}]},
{"role": "user", "parts": [{"text": "He no went to the market."}]},
{"role": "model", "parts": [{"text": "He did not go to the market."}]},
]
)

prompt = "please say no."
prompt = "She no went to the market."
response = chat.send_message(prompt)

text = response.text
Expand Down

0 comments on commit 3eac86d

Please sign in to comment.