Skip to content

Commit

Permalink
fix issue for gemma-2 models.
Browse files Browse the repository at this point in the history
  • Loading branch information
smalltong02 committed Jun 30, 2024
1 parent dc2d15f commit 3e178bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion WebUI/Server/funcall/google_toolboxes/gmap_funcall.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def GetPrice(price_level: int = 2):
properties={
'origin':genai.protos.Schema(type=genai.protos.Type.STRING, description="""Starting address, When the location is "", it means that you are in the current location."""),
'destination':genai.protos.Schema(type=genai.protos.Type.STRING, description="""Destination address, When the location is "", it means that you are in the current location."""),
'mode':genai.protos.Schema(type=genai.protos.Type.STRING, enum=["driving", "walking", "bicycling", "transit"], description="""Specifies the mode of transport to use when calculating directions. One of "driving", "walking", "bicycling" or "transit"."""),
'mode':genai.protos.Schema(type=genai.protos.Type.STRING, description="""Specifies the mode of transport to use when calculating directions. One of "driving", "walking", "bicycling" or "transit"."""),
},
required=['origin', 'destination', 'mode']
)
Expand Down
12 changes: 11 additions & 1 deletion WebUI/configs/specialmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ async def special_chat_iterator(model: Any,
modelconfig = GetModelConfig(webui_config, modelinfo)
loadtype = modelconfig["load_type"]

if model_name.startswith("gemma-"):
if history and history[0]['role'] == 'system':
history.insert(1, {'content': 'I will strictly follow your request.', 'role': 'assistant'})
updated_history = [
{'parts': entry['content'], **({'role': 'model'} if entry['role'] == 'assistant' else {'role': "user"})}
for entry in history
]
history = updated_history

docs = []
btalk = True
while btalk:
Expand Down Expand Up @@ -341,7 +350,8 @@ def running_chain(chain, query):
calling_tools = GetGoogleNativeTools()
model = genai.GenerativeModel(model_name=model_name, tools=calling_tools)
generation_config = {'temperature': temperature}

if history and history[0]['role'] == 'system':
history.insert(1, {'content': 'I will strictly follow your request.', 'role': 'assistant'})
updated_history = [
{'parts': entry['content'], **({'role': 'model'} if entry['role'] == 'assistant' else {'role': "user"})}
for entry in history
Expand Down
2 changes: 1 addition & 1 deletion WebUI/webui_pages/dialogue/dialogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def recorder_factory():
if current_location:
current_coordinates = [current_location['lat'], current_location['lng']]
m = folium.Map(location=current_coordinates, zoom_start=16)
folium.Marker(current_coordinates, icon=folium.Icon(color="blue", prefix='fa'), popup=start_name, tooltip="Start").add_to(m)
folium.Marker(current_coordinates, icon=folium.Icon(color="blue", prefix='fa'), popup="Start", tooltip=start_name).add_to(m)
for location in locations:
place_name = location["name"]
#place_status = location["status"]
Expand Down

0 comments on commit 3e178bc

Please sign in to comment.