Skip to content

Commit

Permalink
docs: README for usage
Browse files Browse the repository at this point in the history
Signed-off-by: Hunter Gregory <[email protected]>
  • Loading branch information
huntergregory committed Jul 19, 2024
1 parent a1f7382 commit e3462f4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
21 changes: 21 additions & 0 deletions ai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Retina AI

## Usage

- Change into this *ai/* folder.
- `go mod tidy ; go mod vendor`
- Set your `kubeconfigPath` in *main.go*.
- If using Azure OpenAI:
- Make sure you're logged into your account/subscription in your terminal.
- Specify environment variables for Deployment name and Endpoint URL. Get deployment from e.g. [https://oai.azure.com/portal/deployment](https://oai.azure.com/portal/deployment) and Endpoint from e.g. Deployment > Playground > Code.
- Linux:
- read -p "Enter AOAI_COMPLETIONS_ENDPOINT: " AOAI_COMPLETIONS_ENDPOINT && export AOAI_COMPLETIONS_ENDPOINT=$AOAI_COMPLETIONS_ENDPOINT
- read -p "Enter AOAI_DEPLOYMENT_NAME: " AOAI_DEPLOYMENT_NAME && export AOAI_DEPLOYMENT_NAME=$AOAI_DEPLOYMENT_NAME
- Windows:
- $env:AOAI_COMPLETIONS_ENDPOINT = Read-Host 'Enter AOAI_COMPLETIONS_ENDPOINT'
- $env:AOAI_DEPLOYMENT_NAME = Read-Host 'Enter AOAI_DEPLOYMENT_NAME'
- `go run main.go`

## Development

Modify prompts in the folders within *pkg/analysis/* (e.g. *pkg/analysis/flows/prompt.go* or *analyzer.go*)
4 changes: 3 additions & 1 deletion ai/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (
"k8s.io/client-go/tools/clientcmd"
)

const kubeconfigPath = "C:\\Users\\hgregory\\.kube\\config" // "/home/hunter/.kube/config"
const kubeconfigPath = "/home/hunter/.kube/config"

// const kubeconfigPath = "C:\\Users\\hgregory\\.kube\\config"

func main() {
log := logrus.New()
Expand Down
9 changes: 6 additions & 3 deletions ai/pkg/lm/azure-openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,22 @@ type AzureOpenAI struct {
client *azopenai.Client
}

// $env:AOAI_COMPLETIONS_ENDPOINT = Read-Host 'Enter AOAI_COMPLETIONS_ENDPOINT'
// $env:AOAI_DEPLOYMENT_NAME = Read-Host 'Enter AOAI_DEPLOYMENT_NAME'

func NewAzureOpenAI() (*AzureOpenAI, error) {
aoai := &AzureOpenAI{}

// Ex: "https://<your-azure-openai-host>.openai.azure.com"
azureOpenAIEndpoint := os.Getenv("AOAI_COMPLETIONS_ENDPOINT")
if azureOpenAIEndpoint == "" {
return nil, fmt.Errorf("set endpoint with environment variable AOAI_COMPLETIONS_ENDPOINT")
}
if !endpointRegex.MatchString(azureOpenAIEndpoint) {
return nil, fmt.Errorf("invalid Azure OpenAI endpoint. must follow pattern: %s", endpointPattern)
}

modelDeployment := os.Getenv("AOAI_DEPLOYMENT_NAME")
if modelDeployment == "" {
return nil, fmt.Errorf("set model deployment name with environment variable AOAI_DEPLOYMENT_NAME")
}
if !deploymentRegex.MatchString(modelDeployment) {
return nil, fmt.Errorf("invalid Azure OpenAI deployment name. must follow pattern: %s", deploymentPattern)
}
Expand Down

0 comments on commit e3462f4

Please sign in to comment.