url \
-H 'Content-Type: application/json' \
-d '{"contents":[{"parts":[{"text":"Explain how AI works"}]}]}' \
-X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=YOUR_API_KEY'
其中
Explain how AI works
为发送给 Gemini Pro 的文本;YOUR_API_KEY
为申请的 Google API Key
mkdir -pv /opt/geminiprochat
vim /opt/geminiprochat/geminiprochat.yaml
---
# 创建 Namespace
apiVersion: v1
kind: Namespace
metadata:
name: hty1024-app
---
# 创建 Service
apiVersion: v1
kind: Service
metadata:
name: hty1024-app-geminiprochat-service
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: geminiprochat
app.k8s.hty1024.com/version: latest
app.k8s.hty1024.com/resources: service
spec:
type: NodePort
ports:
- port: 3000
targetPort: 3000
nodePort: 30000
selector:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: geminiprochat
app.k8s.hty1024.com/version: latest
app.k8s.hty1024.com/resources: pod
---
# 创建 Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: hty1024-app-geminiprochat-deployment
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: geminiprochat
app.k8s.hty1024.com/version: latest
app.k8s.hty1024.com/resources: deployment
spec:
replicas: 1
minReadySeconds: 30
selector:
matchLabels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: geminiprochat
app.k8s.hty1024.com/version: latest
app.k8s.hty1024.com/resources: pod
template:
metadata:
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: geminiprochat
app.k8s.hty1024.com/version: latest
app.k8s.hty1024.com/resources: pod
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: localtime
hostPath:
path: /etc/localtime
- name: shanghai
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai
containers:
- name: geminiprochat
image: babaohuang/geminiprochat:latest
ports:
- name: tcp
containerPort: 3000
volumeMounts:
- name: shanghai
mountPath: /etc/localtime
readOnly: true
env:
- name: GEMINI_API_KEY
value: "123456"
- name: SITE_PASSWORD
value: "1236456"
其中
GEMINI_API_KEY
为 Google API Key;SITE_PASSWORD
为网站密码
kubectl apply -f /opt/geminiprochat/geminiprochat.yaml
url \
-H 'Content-Type: application/json' \
-d '{"contents":[{"parts":[{"text":"Explain how AI works"}]}]}' \
-X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=YOUR_API_KEY'
其中
Explain how AI works
为发送给 Gemini Pro 的文本;YOUR_API_KEY
为申请的 Google API Key
mkdir -pv /opt/geminiprochat
vim /opt/geminiprochat/compose.yaml
version: '3.9'
services:
geminiprochat:
image: babaohuang/geminiprochat:latest
container_name: geminiprochat
restart: always
ports:
- "3000:3000"
environment:
- GEMINI_API_KEY="123456"
- SITE_PASSWORD="123456"
其中
GEMINI_API_KEY
为 Google API Key;SITE_PASSWORD
为网站密码
docker-compose up -d