Skip to content

Cerebras ai #1424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Cerebras ai #1424

wants to merge 7 commits into from

Conversation

mattjoyce
Copy link
Contributor

Add Cerebras AI Integration

This PR adds support for Cerebras AI to the Fabric CLI, enabling users to
access models hosted on the Cerebras platform.

Changes

  • Created a new cerebras package under plugins/ai/
  • Implemented Cerebras client using the OpenAI compatibility layer
  • Added appropriate test files
  • Registered the Cerebras client in the plugin registry

Testing

I've tested the implementation by:

  1. Running fabric --setup to configure the Cerebras API key
  2. Verifying models appear when running fabric -L
  3. Successfully using Cerebras models with patterns

This implementation takes advantage of Cerebras' OpenAI-compatible API,
making the integration straightforward and maintainable.

github-actions bot and others added 3 commits April 17, 2025 21:07
Implements support for the Cerebras AI platform using their OpenAI-compatible
API. Adds a new vendor client that enables users to configure their Cerebras
API key and access Cerebras-hosted models such as llama3.1-8b and llama-3.3-70b.
Copy link
Contributor Author

@mattjoyce mattjoyce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I can;t figure out why it fails formatting checks.

@ksylvan
Copy link
Contributor

ksylvan commented Apr 18, 2025

Sorry I can;t figure out why it fails formatting checks.

Did you gofmt your new code? @mattjoyce

@@ -1 +1 @@
"1.4.172"
"..1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is wrong. You don't actually need to do anything with this file. It's auto-incremented by the build pipeline.

@@ -1,3 +1,3 @@
package main

var version = "v1.4.172"
var version = "v..1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this file. Remove these two files from your PR.

@mattjoyce
Copy link
Contributor Author

I ran gofmt on a missed file, odd I thought vscode did that each save.
@ksylvan what about now?

Copy link
Contributor

@ksylvan ksylvan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattjoyce Put the files back. Don't delete them! 😄 They are edited and committed as part of the build to auto-increment versions. Copy the versions of the files from main branch.

@ksylvan
Copy link
Contributor

ksylvan commented Apr 18, 2025

I checked out your branch.

go test
# github.com/danielmiessler/fabric
./main.go:13:17: undefined: version
FAIL	github.com/danielmiessler/fabric [build failed]

Now do this:

git --no-pager checkout main -- nix/pkgs/fabric/version.nix version.go

And now:

go test ./...
?   	github.com/danielmiessler/fabric	[no test files]
?   	github.com/danielmiessler/fabric/ENV/code_helper	[no test files]
ok  	github.com/danielmiessler/fabric/cli	0.998s
ok  	github.com/danielmiessler/fabric/common	1.106s
ok  	github.com/danielmiessler/fabric/core	0.378s
ok  	github.com/danielmiessler/fabric/plugins	0.161s
ok  	github.com/danielmiessler/fabric/plugins/ai	0.749s
ok  	github.com/danielmiessler/fabric/plugins/ai/anthropic	0.496s
ok  	github.com/danielmiessler/fabric/plugins/ai/azure	0.621s
ok  	github.com/danielmiessler/fabric/plugins/ai/cerebras	1.218s
ok  	github.com/danielmiessler/fabric/plugins/ai/deepseek	1.332s
ok  	github.com/danielmiessler/fabric/plugins/ai/dryrun	1.204s
?   	github.com/danielmiessler/fabric/plugins/ai/exolab	[no test files]
ok  	github.com/danielmiessler/fabric/plugins/ai/gemini	1.193s
?   	github.com/danielmiessler/fabric/plugins/ai/gemini_openai	[no test files]
ok  	github.com/danielmiessler/fabric/plugins/ai/grokai	1.226s
ok  	github.com/danielmiessler/fabric/plugins/ai/groq	1.253s
?   	github.com/danielmiessler/fabric/plugins/ai/litellm	[no test files]
?   	github.com/danielmiessler/fabric/plugins/ai/lmstudio	[no test files]
?   	github.com/danielmiessler/fabric/plugins/ai/mistral	[no test files]
?   	github.com/danielmiessler/fabric/plugins/ai/ollama	[no test files]
ok  	github.com/danielmiessler/fabric/plugins/ai/openai	1.284s
ok  	github.com/danielmiessler/fabric/plugins/ai/openrouter	1.396s [no tests to run]
?   	github.com/danielmiessler/fabric/plugins/ai/siliconcloud	[no test files]
?   	github.com/danielmiessler/fabric/plugins/db	[no test files]
ok  	github.com/danielmiessler/fabric/plugins/db/fsdb	1.504s
?   	github.com/danielmiessler/fabric/plugins/strategy	[no test files]
ok  	github.com/danielmiessler/fabric/plugins/template	2.014s
?   	github.com/danielmiessler/fabric/plugins/tools	[no test files]
?   	github.com/danielmiessler/fabric/plugins/tools/code_helper	[no test files]
ok  	github.com/danielmiessler/fabric/plugins/tools/converter	1.665s
?   	github.com/danielmiessler/fabric/plugins/tools/githelper	[no test files]
?   	github.com/danielmiessler/fabric/plugins/tools/jina	[no test files]
?   	github.com/danielmiessler/fabric/plugins/tools/lang	[no test files]
?   	github.com/danielmiessler/fabric/plugins/tools/to_pdf	[no test files]
?   	github.com/danielmiessler/fabric/plugins/tools/youtube	[no test files]
?   	github.com/danielmiessler/fabric/restapi	[no test files]

@mattjoyce

@ksylvan
Copy link
Contributor

ksylvan commented Apr 18, 2025

@mattjoyce I also ran nix flake check on your branch (via Docker since I wasn't sure I wanted to install nix here yet):

docker run -it -e HOME=/home/user -v $(pwd):/workdir -w /workdir nixos/nix
bash-5.2# cd /workdir/
bash-5.2# nix flake check --extra-experimental-features nix-command --extra-experimental-features flakes
error:
       … while fetching the input 'git+file:///workdir'

       error: opening Git repository "/workdir": repository path '/workdir' is not owned by current user
bash-5.2# git status
fatal: detected dubious ownership in repository at '/workdir'
To add an exception for this directory, call:

	git config --global --add safe.directory /workdir
bash-5.2# echo $HOME
/home/user
bash-5.2# mkdir /home/user
mkdir: cannot create directory '/home/user': No such file or directory
bash-5.2# mkdir -p /home/user
bash-5.2# nix flake check --extra-experimental-features nix-command --extra-experimental-features flakes
error:
       … while fetching the input 'git+file:///workdir'

       error: opening Git repository "/workdir": repository path '/workdir' is not owned by current user
bash-5.2# git config --global --add safe.directory /workdir
bash-5.2# nix flake check --extra-experimental-features nix-command --extra-experimental-features flakes
warning: Git tree '/workdir' is dirty
error: builder for '/nix/store/j81jnkmjflz8lx6zjd66zhngj69qyr2d-treefmt-check.drv' failed with exit code 1;
       last 25 log lines:
       > WARN no formatter for path: web/tsconfig.json
       > WARN no formatter for path: web/vite.config.ts
       > traversed 641 files
       > emitted 111 files for processing
       > formatted 111 files (1 changed) in 58ms
       > On branch main
       > Changes not staged for commit:
       >   (use "git add <file>..." to update what will be committed)
       >   (use "git restore <file>..." to discard changes in working directory)
       >       modified:   plugins/ai/cerebras/cerebras_test.go
       >
       > no changes added to commit (use "git add" and/or "git commit -a")
       > diff --git a/plugins/ai/cerebras/cerebras_test.go b/plugins/ai/cerebras/cerebras_test.go
       > index ef8da76..2a81d03 100644
       > --- a/plugins/ai/cerebras/cerebras_test.go
       > +++ b/plugins/ai/cerebras/cerebras_test.go
       > @@ -19,7 +19,7 @@ func TestNewClient_ConfiguredCorrectly(t *testing.T) {
       >        if client.GetName() != "Cerebras" {
       >             t.Errorf("Expected client name to be 'Cerebras', got '%s'", client.GetName())
       >   }
       > -     
       > +
       >      // Check if the ApiBaseURL is set correctly
       >     if client.ApiBaseURL.Value != "https://api.cerebras.ai/v1" {
       >            t.Errorf("Expected base URL to be 'https://api.cerebras.ai/v1', got '%s'", client.ApiBaseURL.Value)
       For full logs, run:
         nix log /nix/store/j81jnkmjflz8lx6zjd66zhngj69qyr2d-treefmt-check.drv

Looks like the problem is in your test.

@ksylvan
Copy link
Contributor

ksylvan commented Apr 18, 2025

image

@mattjoyce After saving that in VSCode, re-running the nix flake check shows no errors.

@mattjoyce
Copy link
Contributor Author

ok, I think I have it sorted. If not just reject it, and I will resubmit.
Sorry for the trouble, my git-foo is middling, and my nix-foo is nil.

@ksylvan
Copy link
Contributor

ksylvan commented Apr 18, 2025

@mattjoyce please go ahead and close this. I re-created it as #1425

@eugeis please merge 1425.

@ksylvan
Copy link
Contributor

ksylvan commented Apr 18, 2025

Thank you, @mattjoyce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants