Compare commits
1 Commits
delete-fix
...
insecure-r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92e30a62ee |
10
README.md
10
README.md
@@ -125,13 +125,3 @@ Finally, run a model!
|
|||||||
```
|
```
|
||||||
./ollama run llama2
|
./ollama run llama2
|
||||||
```
|
```
|
||||||
|
|
||||||
## REST API
|
|
||||||
|
|
||||||
### `POST /api/generate`
|
|
||||||
|
|
||||||
Generate text from a model.
|
|
||||||
|
|
||||||
```
|
|
||||||
curl -X POST http://localhost:11434/api/generate -d '{"model": "llama2", "prompt":"Why is the sky blue?"}'
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func checkError(resp *http.Response, body []byte) error {
|
|||||||
err := json.Unmarshal(body, &apiError)
|
err := json.Unmarshal(body, &apiError)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Use the full body as the message if we fail to decode a response.
|
// Use the full body as the message if we fail to decode a response.
|
||||||
apiError.ErrorMessage = string(body)
|
apiError.Message = string(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiError
|
return apiError
|
||||||
@@ -92,6 +92,7 @@ func (c *Client) do(ctx context.Context, method, path string, reqData, respData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) stream(ctx context.Context, method, path string, data any, fn func([]byte) error) error {
|
func (c *Client) stream(ctx context.Context, method, path string, data any, fn func([]byte) error) error {
|
||||||
@@ -136,9 +137,9 @@ func (c *Client) stream(ctx context.Context, method, path string, data any, fn f
|
|||||||
|
|
||||||
if response.StatusCode >= 400 {
|
if response.StatusCode >= 400 {
|
||||||
return StatusError{
|
return StatusError{
|
||||||
StatusCode: response.StatusCode,
|
StatusCode: response.StatusCode,
|
||||||
Status: response.Status,
|
Status: response.Status,
|
||||||
ErrorMessage: errorResponse.Error,
|
Message: errorResponse.Error,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
api/types.go
19
api/types.go
@@ -8,23 +8,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type StatusError struct {
|
type StatusError struct {
|
||||||
StatusCode int
|
StatusCode int
|
||||||
Status string
|
Status string
|
||||||
ErrorMessage string `json:"error"`
|
Message string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e StatusError) Error() string {
|
func (e StatusError) Error() string {
|
||||||
switch {
|
if e.Message != "" {
|
||||||
case e.Status != "" && e.ErrorMessage != "":
|
return fmt.Sprintf("%s: %s", e.Status, e.Message)
|
||||||
return fmt.Sprintf("%s: %s", e.Status, e.ErrorMessage)
|
|
||||||
case e.Status != "":
|
|
||||||
return e.Status
|
|
||||||
case e.ErrorMessage != "":
|
|
||||||
return e.ErrorMessage
|
|
||||||
default:
|
|
||||||
// this should not happen
|
|
||||||
return "something went wrong, please see the ollama server logs for details"
|
|
||||||
}
|
}
|
||||||
|
return e.Status
|
||||||
}
|
}
|
||||||
|
|
||||||
type GenerateRequest struct {
|
type GenerateRequest struct {
|
||||||
|
|||||||
@@ -6,12 +6,6 @@ Install required tools:
|
|||||||
brew install go
|
brew install go
|
||||||
```
|
```
|
||||||
|
|
||||||
Enable CGO:
|
|
||||||
|
|
||||||
```
|
|
||||||
export CGO_ENABLED=1
|
|
||||||
```
|
|
||||||
|
|
||||||
Then build ollama:
|
Then build ollama:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -548,13 +548,9 @@ func DeleteModel(name string, fn func(api.ProgressResponse)) error {
|
|||||||
// only delete the files which are still in the deleteMap
|
// only delete the files which are still in the deleteMap
|
||||||
for k, v := range deleteMap {
|
for k, v := range deleteMap {
|
||||||
if v {
|
if v {
|
||||||
fp, err := GetBlobsPath(k)
|
err := os.Remove(k)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("couldn't get file path for '%s': %v", k, err)
|
log.Printf("couldn't remove file '%s': %v", k, err)
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err := os.Remove(fp); err != nil {
|
|
||||||
log.Printf("couldn't remove file '%s': %v", fp, err)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@@ -191,10 +190,6 @@ func ListModelsHandler(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err = filepath.Walk(fp, func(path string, info os.FileInfo, err error) error {
|
err = filepath.Walk(fp, func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
|
||||||
log.Printf("manifest file does not exist: %s", fp)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !info.IsDir() {
|
if !info.IsDir() {
|
||||||
|
|||||||
@@ -11,23 +11,18 @@ export default async function Home() {
|
|||||||
<Image src='/ollama.png' width={64} height={64} alt='ollamaIcon' />
|
<Image src='/ollama.png' width={64} height={64} alt='ollamaIcon' />
|
||||||
<section className='my-12 text-center'>
|
<section className='my-12 text-center'>
|
||||||
<div className='flex flex-col space-y-2'>
|
<div className='flex flex-col space-y-2'>
|
||||||
<h2 className='md:max-w-md mx-auto my-2 text-3xl tracking-tight'>
|
<h2 className='md:max-w-[18rem] mx-auto my-2 text-3xl tracking-tight'>Portable large language models</h2>
|
||||||
Get up and running with large language models, locally.
|
|
||||||
</h2>
|
|
||||||
<h3 className='md:max-w-xs mx-auto text-base text-neutral-500'>
|
<h3 className='md:max-w-xs mx-auto text-base text-neutral-500'>
|
||||||
Run Llama 2 and other models on macOS. Customize and create your own.
|
Bundle a model’s weights, configuration, prompts, data and more into self-contained packages that run anywhere.
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className='mx-auto max-w-xs flex flex-col space-y-4 mt-12'>
|
<div className='mx-auto flex flex-col space-y-4 mt-12'>
|
||||||
<Link
|
<Link href='/download' className='md:mx-10 lg:mx-14 bg-black text-white rounded-full px-4 py-2 focus:outline-none cursor-pointer'>
|
||||||
href='/download'
|
|
||||||
className='md:mx-10 lg:mx-14 bg-black text-white rounded-full px-4 py-2 focus:outline-none cursor-pointer'
|
|
||||||
>
|
|
||||||
Download
|
Download
|
||||||
</Link>
|
</Link>
|
||||||
<p className='text-neutral-500 text-sm '>
|
<p className='text-neutral-500 text-sm '>
|
||||||
Available for macOS with Apple Silicon <br />
|
Available for macOS with Apple Silicon <br />
|
||||||
Windows & Linux support coming soon.
|
Windows & Linux support coming soon.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user