(chat_state, model, conv, temperature, max_tokens)
| 494 | |
| 495 | |
| 496 | def chat_completion_palm(chat_state, model, conv, temperature, max_tokens): |
| 497 | from fastchat.serve.api_provider import init_palm_chat |
| 498 | |
| 499 | assert model == "palm-2-chat-bison-001" |
| 500 | |
| 501 | if chat_state is None: |
| 502 | chat_state = init_palm_chat("chat-bison@001") |
| 503 | |
| 504 | parameters = { |
| 505 | "temperature": temperature, |
| 506 | "top_p": 0.8, |
| 507 | "top_k": 40, |
| 508 | "max_output_tokens": max_tokens, |
| 509 | } |
| 510 | output = API_ERROR_OUTPUT |
| 511 | for _ in range(API_MAX_RETRY): |
| 512 | try: |
| 513 | response = chat_state.send_message(conv.messages[-2][1], **parameters) |
| 514 | output = response.text |
| 515 | break |
| 516 | except Exception as e: |
| 517 | print(type(e), e) |
| 518 | time.sleep(API_RETRY_SLEEP) |
| 519 | return chat_state, output |
| 520 | |
| 521 | |
| 522 | def normalize_game_key_single(gamekey, result): |
no outgoing calls
no test coverage detected
searching dependent graphs…