This repository has been archived by the owner on Jan 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from dabumana/v.0.1.1
V.0.1.1
- Loading branch information
Showing
17 changed files
with
787 additions
and
324 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Package model section | ||
package model | ||
|
||
// PredictProperties - Request model | ||
type PredictProperties struct { | ||
Input []string `json:"input"` | ||
Details PredictResponse `json:"details"` | ||
} | ||
|
||
// PredictRequest - Request model | ||
type PredictRequest struct { | ||
Document string `json:"document"` | ||
} | ||
|
||
// PredictResponse - Response model | ||
type PredictResponse struct { | ||
Documents []Predict `json:"documents"` | ||
} | ||
|
||
// Predict - Document properties model | ||
type Predict struct { | ||
AverageProb float64 `json:"average_generated_prob"` | ||
CompletelyProb float64 `json:"completely_generated_prob"` | ||
OverallBurstiness float64 `json:"overall_burstiness"` | ||
Paragraphs []Paragraph `json:"paragraphs"` | ||
Sentences []Sentence `json:"sentences"` | ||
} | ||
|
||
// Sentence - Nested sentence model | ||
type Sentence struct { | ||
GeneratedProb int `json:"generated_prob"` | ||
Perplexity int `json:"perplexity"` | ||
Sentence string `json:"sentence"` | ||
} | ||
|
||
// Paragraph - Nested paragraphs model | ||
type Paragraph struct { | ||
CompletelyProb float64 `json:"completely_generated_prob"` | ||
NumberSentences int `json:"num_sentences"` | ||
Index int `json:"start_sentence_index"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Package service section | ||
package service | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"net/http" | ||
"os" | ||
|
||
"caos/model" | ||
|
||
"github.com/PullRequestInc/go-gpt3" | ||
"github.com/joho/godotenv" | ||
) | ||
|
||
// Agent - Contextual client API | ||
type Agent struct { | ||
ctx context.Context | ||
client gpt3.Client | ||
exClient *http.Client | ||
engineProperties model.EngineProperties | ||
promptProperties model.PromptProperties | ||
predictProperties model.PredictProperties | ||
} | ||
|
||
// Initialize - Creates context background to be used along with the client | ||
func (c Agent) Initialize() Agent { | ||
c.ctx = context.Background() | ||
c.client, c.exClient = c.Connect() | ||
return c | ||
} | ||
|
||
// Connect - Contextualize the API to create a new client | ||
func (c Agent) Connect() (gpt3.Client, *http.Client) { | ||
godotenv.Load() | ||
|
||
apiKey := os.Getenv("API_KEY") | ||
if apiKey == "" { | ||
log.Fatalln("Missing API KEY") | ||
} | ||
|
||
client := gpt3.NewClient(apiKey) | ||
externalClient := http.Client{ | ||
Transport: http.DefaultTransport, | ||
} | ||
|
||
c.client = client | ||
c.exClient = &externalClient | ||
|
||
return c.client, c.exClient | ||
} | ||
|
||
// SetEngineParameters - Set engine parameters for the current prompt | ||
func (c Agent) SetEngineParameters(pmodel string, temperature float32, topp float32, penalty float32, frequency float32) model.EngineProperties { | ||
properties := model.EngineProperties{ | ||
Model: pmodel, | ||
Temperature: temperature, | ||
TopP: topp, | ||
PresencePenalty: penalty, | ||
FrequencyPenalty: frequency, | ||
} | ||
return properties | ||
} | ||
|
||
// SetPromptParameters - Set request parameters for the current prompt | ||
func (c Agent) SetPromptParameters(promptContext []string, instruction []string, tokens int, results int, probabilities int) model.PromptProperties { | ||
properties := model.PromptProperties{ | ||
PromptContext: promptContext, | ||
Instruction: instruction, | ||
MaxTokens: tokens, | ||
Results: results, | ||
Probabilities: probabilities, | ||
} | ||
return properties | ||
} | ||
|
||
// SetPredictionParameters - Set prediction parameters for the current prompt | ||
func (c Agent) SetPredictionParameters(prompContext []string) model.PredictProperties { | ||
properties := model.PredictProperties{ | ||
Input: prompContext, | ||
} | ||
return properties | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.