Skip to content

Commit

Permalink
fixed changed model behaviour and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gotochkin committed Dec 9, 2024
1 parent 0036558 commit 5b7bbe6
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 8 deletions.
76 changes: 70 additions & 6 deletions infrastructure/cymbal-store-embeddings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,84 @@ gcloud alpha run deploy cymbal-store \
--set-env-vars=DB_USER=cymbaldb_owner,DB_PASS=StrongPassword,DB_NAME=cymbaldb,INSTANCE_HOST=127.0.0.1,DB_PORT=5432 \
--quiet
```
### Deploy the applicaion to GKE
- Grant to the default GCE service account ([email protected]) roles/artifactregistry.reader role
- Create artifact registry repository
```
gcloud artifacts repositories create cymbal-store-embeddings --location us-central1 --repository-format=docker --project $PROJECT_ID
```
- Build the image
```
gcloud builds submit --pack image=us-central1-docker.pkg.dev/$PROJECT_ID/cymbal-store-embeddings/cymbal_store .
```
- Create secret
```
kubectl create secret generic cymbal-store-embeddings-secret \
--from-literal=database=cymbal_store \
--from-literal=username=cymbal \
--from-literal=password=ChangeMe123
```
- Create manifest file
```
apiVersion: apps/v1
kind: Deployment
metadata:
name: cymbal-store-embeddings
spec:
selector:
matchLabels:
app: cymbal-store
template:
metadata:
labels:
app: cymbal-store
spec:
containers:
- name: cymbal-store
# Replace <PROJECT_ID> and <REGION> with your project ID and region.
image: us-central1-docker.pkg.dev/$PROJECT_ID/cymbal-store-embeddings/cymbal_store:latest
imagePullPolicy: Always
# This app listens on port 8080 for web traffic by default.
ports:
- containerPort: 8080
env:
- name: PORT
value: "8080"
- name: INSTANCE_HOST
value: "34.118.228.131"
- name: DB_PORT
value: "5432"
- name: DB_USER
valueFrom:
secretKeyRef:
name: cymbal-store-embeddings-secret
key: username
- name: DB_PASS
valueFrom:
secretKeyRef:
name: cymbal-store-embeddings-secret
key: password
- name: DB_NAME
valueFrom:
secretKeyRef:
name: cymbal-store-embeddings-secret
key: database
```
- Apply the manifest
- Create service

### Use the application
#### Choose the model
- Click "Model" on the bottom of the application and new dialog window will be opened
![Choose the model](./cymbal-store-embeddings-01.png)
- Provide your Google AI API token
- Switch focus to models and click checkbox for Gemeini 1.5 flash model
- Switch focus to models and click checkbox for Gemini 1.5 flash model
- Click "Confirm"

#### Ask questions
- Ask questions in the chat
- Please report all the issues with the application
- Requests to Try
- Choose model using button in the chat and providing your Google AI token and choosing the Gemini model (Open AI is not supported yet)
- Confirm the choice of the model
- Ask in the chat - "What kind of fruit trees grow well here?"
![CPost the question](./cymbal-store-embeddings-02.png)
- Ask in the chat - "What kind of fruit trees grow well here?"

# TO DO
- Add support for other models and providers
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion infrastructure/cymbal-store-embeddings/cymbal_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def send_prompt(e: me.ClickEvent):
search_embedding = gemini_model.generate_embedding(json_intent["summary"])
products_list = get_products(db, str(search_embedding["embedding"]))
logging.info(f"PRODUCTS LIST: {products_list}")
print(products_list)
print(f"PRODUCTS LIST: {products_list}")
persona="You are friendly assistance in a store helping to find a products based on the client's request"
safeguards="You should give information about the product, price and any supplemental information. Do not invent any new products and use for the answer the product defined in the context"
context="""
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/cymbal-store-embeddings/gemini_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def classify_intent(input: str) -> str:
)
json_resp = model.generate_content(input)
logging.info(f"INTENT: {json_resp}")
return json_resp.text
return json_resp.text.replace("```", "").replace("json", "").strip()

def generate_embedding(input: str) -> list[float]:
result = genai.embed_content(
Expand Down

0 comments on commit 5b7bbe6

Please sign in to comment.