| | |
| | | package com.yb.util; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.google.gson.Gson; |
| | | import com.yb.entity.ResponseEntity; |
| | | import okhttp3.*; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Component |
| | | @RestController |
| | |
| | | // get请求 |
| | | public String getMessage(String url) { |
| | | try { |
| | | OkHttpClient client = new OkHttpClient(); |
| | | OkHttpClient client = new OkHttpClient.Builder() |
| | | .connectTimeout(5, TimeUnit.SECONDS) |
| | | .readTimeout(5, TimeUnit.SECONDS) |
| | | .writeTimeout(5, TimeUnit.SECONDS) |
| | | .build(); |
| | | Request request = new Request.Builder() |
| | | |
| | | .url(url) |
| | | .build(); |
| | | |
| | |
| | | return null ; |
| | | } |
| | | |
| | | @Async |
| | | public String requesFast(String message){ |
| | | System.out.println("fastgpt:"+message) ; |
| | | OkHttpClient client = new OkHttpClient(); |
| | |
| | | int index = rep.indexOf("flowResponses"); |
| | | int index_s = rep.indexOf("data", index); |
| | | String data = rep.substring(index_s + 5); |
| | | System.out.println(data); |
| | | System.out.println("data is ok...."); |
| | | return data; |
| | | }else{ |
| | | return rep ; |