Skip to content

Add groq example with llama #192

Add groq example with llama

Add groq example with llama #192

Workflow file for this run

name: e2e tests
on:
pull_request:
jobs:
e2e-tests:
runs-on: ubuntu-latest
env:
NETWORK: "localhost"
ORACLE_ADDRESS: "0x5FbDB2315678afecb367f032d93F642f64180aa3"
TEST_CONTRACT_ADDRESS: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"
IMAGE_URL: "https://picsum.photos/200/300"
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: contracts/package-lock.json
- name: "Install Dependencies"
id: install
run: cd contracts && npm ci
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Cache pip
uses: actions/cache@v4
with:
path: |
~/.cache/pip
!~/.cache/pip/log
key: ${{ runner.os }}-pip-${{ hashFiles('oracles/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python Dependencies
run: pip install -r oracles/requirements.txt
- name: Run Hardhat Node
run: cd contracts && npx hardhat node &
- name: "Deploy Contracts"
run:
cd contracts && npm run deployAll:localhost
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Whitelist the address"
run:
cd contracts && npx hardhat whitelist --oracle-address ${{ env.ORACLE_ADDRESS }} --whitelist-address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --network localhost
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Deploy Test Contract"
run:
cd contracts && npm run deployTest:localhost
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
ORACLE_ADDRESS: ${{ env.ORACLE_ADDRESS }}
- name: Run Python Oracle
run: |
cd oracles && python oracle.py > oracle_output.txt 2>&1 &
echo $! > python_oracle.pid
env:
CHAIN_ID: 1337
WEB3_RPC_URL: "http://127.0.0.1:8545/"
ORACLE_ADDRESS: ${{ env.ORACLE_ADDRESS }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
OPEN_AI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
SERPER_API_KEY: ${{ secrets.SERPER_API_KEY }}
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
PINATA_GATEWAY_TOKEN: ${{ secrets.PINATA_GATEWAY_TOKEN }}
PINATA_API_JWT: ${{ secrets.PINATA_API_JWT }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- name: "OpenAI gpt-4-turbo-preview"
run:
cd contracts && npx hardhat openai --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model gpt-4-turbo-preview --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "OpenAI gpt-3.5-turbo-1106"
run:
cd contracts && npx hardhat openai --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model gpt-3.5-turbo-1106 --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "OpenAI gpt-4-turbo vision"
run:
cd contracts && npx hardhat openai_vision --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model gpt-4-turbo --message "What is on this image?" --image-url ${{env.IMAGE_URL}} --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "OpenAI gpt-4o"
run:
cd contracts && npx hardhat openai_vision --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model gpt-4o --message "What is on this image?" --image-url ${{env.IMAGE_URL}} --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Groq llama3-8b-8192"
run:
cd contracts && npx hardhat groq --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model llama3-8b-8192 --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Groq llama3-70b-8192"
run:
cd contracts && npx hardhat groq --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model llama3-70b-8192 --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Groq mixtral-8x7b-32768"
run:
cd contracts && npx hardhat groq --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model mixtral-8x7b-32768 --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Groq gemma-7b-it"
run:
cd contracts && npx hardhat groq --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model gemma-7b-it --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Anthropic claude-3-5-sonnet-20240620"
run:
cd contracts && npx hardhat llm --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model claude-3-5-sonnet-20240620 --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "OpenAI Image Generation"
run:
cd contracts && npx hardhat image_generation --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --query "Red rose" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Tool Web search"
run:
cd contracts && npx hardhat web_search --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --query "Capital of Germany" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Tool Code interpreter"
run:
cd contracts && npx hardhat code_interpreter --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --query "print(2+2)" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "RAG Add knowledge base"
run:
cd contracts && npx hardhat add_knowledge_base --oracle-address ${{ env.ORACLE_ADDRESS }} --cid QmdCgbMawRVE6Kc1joZmhgDo2mSZFgRgWvBCqUvJV9JwkF --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "RAG Query knowledge base"
run:
cd contracts && npx hardhat query_knowledge_base --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --cid QmdCgbMawRVE6Kc1joZmhgDo2mSZFgRgWvBCqUvJV9JwkF --query "What is the oracle smart contract address?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: Display Oracle Output
if: always() # Ensures this step runs even if a previous step fails
run: cat oracles/oracle_output.txt
- name: Wait for Metrics File Creation
run: sleep 10
- name: Check Metrics File
run: test -f oracles/metrics.json && echo "metrics.json exists."
- name: Validate Metrics Content
run: cd oracles && python tests/e2e/check_metrics.py