otiai10/openaigo

View on GitHub

Showing 9 of 9 total issues

Client has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

func (client *Client) ListModels(ctx context.Context) (resp ModelsListResponse, err error) {
    p := "/models"
    return call(ctx, client, http.MethodGet, p, nil, resp, nil)
}
Severity: Minor
Found in endpoints.go - About 3 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                    if res_1.Choices[0].Message.FunctionCall != nil {
                        fmt.Printf("%+v\n", res_1.Choices[0].Message.FunctionCall)
                        conversation = append(conversation, openaigo.Message{
                            Role:    "function",
                            Name:    res_1.Choices[0].Message.FunctionCall.Name(),
    Severity: Major
    Found in testapp/main.go and 1 other location - About 1 hr to fix
    testapp/main.go on lines 190..197

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 132.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                    if res_2.Choices[0].Message.FunctionCall != nil {
                        fmt.Printf("%+v\n", res_2.Choices[0].Message.FunctionCall)
                        conversation = append(conversation, openaigo.Message{
                            Role:    "function",
                            Name:    res_2.Choices[0].Message.FunctionCall.Name(),
    Severity: Major
    Found in testapp/main.go and 1 other location - About 1 hr to fix
    testapp/main.go on lines 176..183

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 132.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method ImageEditRequestBody.ToMultipartFormData has 7 return statements (exceeds 4 allowed).
    Open

    func (body ImageEditRequestBody) ToMultipartFormData() (buf *bytes.Buffer, contenttype string, err error) {
        if body.Image == nil {
            return nil, "", fmt.Errorf("body.Image must not be nil")
        }
        buf = bytes.NewBuffer(nil)
    Severity: Major
    Found in image.go - About 45 mins to fix

      Method Client.RetrieveFileContent has 5 return statements (exceeds 4 allowed).
      Open

      func (client *Client) RetrieveFileContent(ctx context.Context, id string) (res io.ReadCloser, err error) {
          endpoint, err := client.endpoint(fmt.Sprintf("/files/%s/content", id))
          if err != nil {
              return nil, err
          }
      Severity: Major
      Found in endpoints.go - About 35 mins to fix

        Method Funcs.invoke has 5 return statements (exceeds 4 allowed).
        Open

        func (funcs Funcs) invoke(invocation Invocation) any {
            f, ok := funcs[invocation.Name()]
            if !ok {
                return fmt.Sprintf("function not found: `%s`", invocation.Name())
            }
        Severity: Major
        Found in functioncall/invoke.go - About 35 mins to fix

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                  {
                      Name: "chat_completion",
                      Run: func() (any, error) {
                          client := openaigo.NewClient(OPENAI_API_KEY)
                          request := openaigo.ChatRequest{
          Severity: Minor
          Found in testapp/main.go and 2 other locations - About 30 mins to fix
          testapp/main.go on lines 37..49
          testapp/main.go on lines 97..110

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 100.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                  {
                      // https://platform.openai.com/docs/models/gpt-4
                      Name: "[SKIP] chat_completion_GPT4",
                      Run: func() (any, error) {
                          client := openaigo.NewClient(OPENAI_API_KEY)
          Severity: Minor
          Found in testapp/main.go and 2 other locations - About 30 mins to fix
          testapp/main.go on lines 37..49
          testapp/main.go on lines 84..96

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 100.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                  {
                      Name: "completion",
                      Run: func() (any, error) {
                          client := openaigo.NewClient(OPENAI_API_KEY)
                          request := openaigo.ChatCompletionRequestBody{
          Severity: Minor
          Found in testapp/main.go and 2 other locations - About 30 mins to fix
          testapp/main.go on lines 84..96
          testapp/main.go on lines 97..110

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 100.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language