@@ -1287,6 +1287,7 @@ class CodeChatModel(_ChatModelBase):
1287
1287
code_chat_model = CodeChatModel.from_pretrained("codechat-bison@001")
1288
1288
1289
1289
code_chat = code_chat_model.start_chat(
1290
+ context="I'm writing a large-scale enterprise application.",
1290
1291
max_output_tokens=128,
1291
1292
temperature=0.2,
1292
1293
)
@@ -1301,6 +1302,7 @@ class CodeChatModel(_ChatModelBase):
1301
1302
def start_chat (
1302
1303
self ,
1303
1304
* ,
1305
+ context : Optional [str ] = None ,
1304
1306
max_output_tokens : Optional [int ] = None ,
1305
1307
temperature : Optional [float ] = None ,
1306
1308
message_history : Optional [List [ChatMessage ]] = None ,
@@ -1309,6 +1311,9 @@ def start_chat(
1309
1311
"""Starts a chat session with the code chat model.
1310
1312
1311
1313
Args:
1314
+ context: Context shapes how the model responds throughout the conversation.
1315
+ For example, you can use context to specify words the model can or
1316
+ cannot use, topics to focus on or avoid, or the response format or style.
1312
1317
max_output_tokens: Max length of the output text in tokens. Range: [1, 1000].
1313
1318
temperature: Controls the randomness of predictions. Range: [0, 1].
1314
1319
stop_sequences: Customized stop sequences to stop the decoding process.
@@ -1318,6 +1323,7 @@ def start_chat(
1318
1323
"""
1319
1324
return CodeChatSession (
1320
1325
model = self ,
1326
+ context = context ,
1321
1327
max_output_tokens = max_output_tokens ,
1322
1328
temperature = temperature ,
1323
1329
message_history = message_history ,
@@ -1653,13 +1659,15 @@ class CodeChatSession(_ChatSessionBase):
1653
1659
def __init__ (
1654
1660
self ,
1655
1661
model : CodeChatModel ,
1662
+ context : Optional [str ] = None ,
1656
1663
max_output_tokens : Optional [int ] = None ,
1657
1664
temperature : Optional [float ] = None ,
1658
1665
message_history : Optional [List [ChatMessage ]] = None ,
1659
1666
stop_sequences : Optional [List [str ]] = None ,
1660
1667
):
1661
1668
super ().__init__ (
1662
1669
model = model ,
1670
+ context = context ,
1663
1671
max_output_tokens = max_output_tokens ,
1664
1672
temperature = temperature ,
1665
1673
message_history = message_history ,
0 commit comments