|
2 | 2 | from pytest_mock import MockerFixture |
3 | 3 |
|
4 | 4 | from ai21.ai21_http_client import AI21HTTPClient |
| 5 | +from ai21.clients.studio.resources.chat import ChatCompletions |
5 | 6 | from ai21.clients.studio.resources.studio_answer import StudioAnswer |
6 | 7 | from ai21.clients.studio.resources.studio_chat import StudioChat |
7 | 8 | from ai21.clients.studio.resources.studio_completion import StudioCompletion |
|
43 | 44 | SummarizeBySegmentResponse, |
44 | 45 | SegmentSummary, |
45 | 46 | ) |
| 47 | +from ai21.models.chat import ( |
| 48 | + ChatMessage as ChatCompletionChatMessage, |
| 49 | + ChatCompletionResponse, |
| 50 | + ChatCompletionResponseChoice, |
| 51 | +) |
46 | 52 | from ai21.models.responses.segmentation_response import Segment |
| 53 | +from ai21.models.usage_info import UsageInfo |
47 | 54 | from ai21.utils.typing import to_lower_camel_case |
48 | 55 |
|
49 | 56 |
|
@@ -110,6 +117,45 @@ def get_studio_chat(): |
110 | 117 | ) |
111 | 118 |
|
112 | 119 |
|
| 120 | +def get_chat_completions(): |
| 121 | + _DUMMY_MODEL = "dummy-chat-model" |
| 122 | + _DUMMY_MESSAGES = [ |
| 123 | + ChatCompletionChatMessage(content="Hello, I need help with a signup process.", role=RoleType.USER), |
| 124 | + ChatCompletionChatMessage( |
| 125 | + content="Hi Alice, I can help you with that. What seems to be the problem?", |
| 126 | + role=RoleType.ASSISTANT, |
| 127 | + ), |
| 128 | + ] |
| 129 | + |
| 130 | + return ( |
| 131 | + ChatCompletions, |
| 132 | + {"model": _DUMMY_MODEL, "messages": _DUMMY_MESSAGES}, |
| 133 | + "chat/complete", |
| 134 | + { |
| 135 | + "model": _DUMMY_MODEL, |
| 136 | + "messages": [message.to_dict() for message in _DUMMY_MESSAGES], |
| 137 | + }, |
| 138 | + ChatCompletionResponse( |
| 139 | + id="some-id", |
| 140 | + choices=[ |
| 141 | + ChatCompletionResponseChoice( |
| 142 | + index=0, |
| 143 | + message=ChatCompletionChatMessage( |
| 144 | + content="Hello, I need help with a signup process.", role=RoleType.USER |
| 145 | + ), |
| 146 | + finish_reason="dummy_reason", |
| 147 | + logprobs=None, |
| 148 | + ) |
| 149 | + ], |
| 150 | + usage=UsageInfo( |
| 151 | + prompt_tokens=10, |
| 152 | + completion_tokens=20, |
| 153 | + total_tokens=30, |
| 154 | + ), |
| 155 | + ), |
| 156 | + ) |
| 157 | + |
| 158 | + |
113 | 159 | def get_studio_completion(**kwargs): |
114 | 160 | _DUMMY_MODEL = "dummy-completion-model" |
115 | 161 | _DUMMY_PROMPT = "dummy-prompt" |
|
0 commit comments