Skip to content

Commit

Permalink
Add llama-3.1-70b-versatile and llama-3.1-8b-instant support for groq…
Browse files Browse the repository at this point in the history
…. Fix chat format for Groq.
  • Loading branch information
kristjanpeterson1 committed Jul 25, 2024
1 parent 7c2194e commit 3154bdb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion contracts/contracts/GroqChatGpt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract GroqChatGpt {
chatRunsCount = 0;

config = IOracle.GroqRequest({
model : "mixtral-8x7b-32768",
model : "llama-3.1-8b-instant",
frequencyPenalty : 21, // > 20 for null
logitBias : "", // empty str for null
maxTokens : 1000, // 0 for null
Expand Down
1 change: 0 additions & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"node": "npx hardhat node",
"compile": "npx hardhat compile",
"test": "npx hardhat test",
"whitelist": "npx hardhat run scripts/whitelist.ts --network galadriel",
"deployAll:localhost": "npx hardhat run scripts/deployAll.ts --network localhost",
"deployAll:galadriel": "npx hardhat run scripts/deployAll.ts --network galadriel",
"deployQuickstart": "npx hardhat run scripts/deployQuickstart.ts --network galadriel",
Expand Down
11 changes: 5 additions & 6 deletions contracts/tasks/whitelist.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { task } from "hardhat/config";

// Define the task with the name 'whitelist-address'
export const whitelistTask = task("whitelist", "Whitelists an address in the Oracle contract")
.addParam("oracleAddress", "The address of the Oracle contract")
.addParam("whitelistAddress", "The address to whitelist")
task("whitelist", "Whitelists an address in the Oracle contract")
.addParam("oracleaddress", "The address of the Oracle contract")
.addParam("whitelistaddress", "The address to whitelist")
.setAction(async (taskArgs, hre) => {
const oracleContractAddress = taskArgs.oracleAddress;
const whitelistAddress = taskArgs.whitelistAddress;
const oracleContractAddress = taskArgs.oracleaddress;
const whitelistAddress = taskArgs.whitelistaddress;
const pcr0Hash = "5c8ce02f8c739a6578886ef009dc27dc69ac85a631689b093f75f6ae238e10d70a08dce8f0cafdd1f7d9b3a26c889565";

const contractABI = [
Expand Down
12 changes: 7 additions & 5 deletions oracles/src/domain/llm/groq_llm.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import backoff
from typing import Optional

import backoff
import groq
from groq import AsyncGroq
from openai.types.chat import ChatCompletion
from openai.types.chat.chat_completion import ChatCompletion
from groq.types.chat import ChatCompletion as GroqChatCompletion
from openai.types.chat.chat_completion import ChatCompletion

from src.entities import Chat
from src.domain.llm.utils import TIMEOUT
import settings
from src.domain.llm.utils import TIMEOUT
from src.entities import Chat


@backoff.on_exception(
Expand All @@ -20,6 +19,9 @@ async def execute(chat: Chat) -> Optional[GroqChatCompletion]:
api_key=settings.GROQ_API_KEY,
timeout=TIMEOUT,
)
for message in chat.messages:
if len(message.get("content")) and message.get("content")[0].get("text"):
message["content"] = message.get("content")[0].get("text")
chat_completion: ChatCompletion = await client.chat.completions.create(
messages=chat.messages,
model=chat.config.model,
Expand Down
7 changes: 6 additions & 1 deletion oracles/src/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
"gpt-4o", "gpt-4-turbo", "gpt-4-turbo-preview", "gpt-3.5-turbo-1106"
]
GroqModelType = Literal[
"llama3-8b-8192", "llama3-70b-8192", "mixtral-8x7b-32768", "gemma-7b-it"
"llama-3.1-70b-versatile",
"llama-3.1-8b-instant",
"llama3-70b-8192",
"llama3-8b-8192",
"mixtral-8x7b-32768",
"gemma-7b-it",
]
AnthropicModelType = Literal[
"claude-3-5-sonnet-20240620",
Expand Down

0 comments on commit 3154bdb

Please sign in to comment.